Solved

IS this possible in Access/VB

Posted on 2003-11-26
9
527 Views
Last Modified: 2010-04-17
Ok I need to know if I am doing something incorrectly or if this just isn't possible:

I have my main DB running in SQL Server 2000 on my ISPs machine.
I need to copy the tables to an Access DB on my machine.

I can copy the data by opening two connections, creating a recordset and looping through
inserting to the access db. But this is very slow.

What I'd like to do is:
Drop the table in question from the local access db : No problems here
Connect to the remote SQL db : No problems here either

Then I would like to create a new table in the access db using the following select statement:

strSQL = "SELECT tblOld.* INTO NewTable IN 'D:\Path\OfflineDB.mdb' FROM tblOld;"

When I run the statement I get the following error:

Run-Time Error -2147217900 (80040e14):
Incorrect Syntax Near Keyword 'IN'

Is this just something that cannot be done in Access (2000)?



0
Comment
Question by:gerryjc
9 Comments
 
LVL 4

Expert Comment

by:JNSTAUB
ID: 9824735
if your db is in access format on your server ,just create an admin page protected by password with a link to the db to download .easy!!
or create a connectio n, create a table in your local access db and update the created table by an update query.
0
 
LVL 2

Author Comment

by:gerryjc
ID: 9825387
The database is not in Access format on the server.

The reason I am trying to do it this particular way is that it would eliminate the need to redistribute the database to all my client machines if I happened to make a small change to db structure.
0
 
LVL 2

Author Comment

by:gerryjc
ID: 9825505
OK I think I've Realised Whats Going on Here,

It may be that the command is actually trying to create the table in the path specified on the remote machine...hence the error code for a permissions error!

I don't suppose anyone would know a way around this problem?
0
 

Expert Comment

by:HelgeGudmundsen
ID: 9826433
If you are using Access, you could try using DoCmd.TransferDatabase to get the table copied:

TransferDatabase(TransferType, DatabaseType, DatabaseName, ObjectType, Source, Destination, StructureOnly, StoreLogin)

I am using this command to do what you want, dropping a local table and copying an external table. In my case I am connecting to another Access database, but if you have an ODBC-connection to the SQL-server, the same method should work for you.

In my program the actual call to do this looks like this:

DoCmd.TransferDatabase acImport, "Microsoft Access", strPath, acTable, strSingleTable, strSingleTable

The VBA helpfile has this example showing how to link an external table via an ODBC-link.

DoCmd.TransferDatabase acLink, "ODBC Database", _
    "ODBC;DSN=DataSource1;UID=User2;PWD=www;LANGUAGE=us_english;" _
    & "DATABASE=pubs", acTable, "Authors", "dboAuthors"

HTH
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 9

Expert Comment

by:bhagyesht
ID: 9830150
why dont you just import the tables to access directly? using an SQL server driver and odbc which points to the server?
0
 
LVL 2

Author Comment

by:gerryjc
ID: 9837151
THe problem is that thi sis being executed from within a VB 6.0 application, I don't want the user to have anything to do with it.
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9837235
I guess you can do that from vb too.
create a dsn and use access.application
then use docmd and transferdatabase
0
 
LVL 6

Accepted Solution

by:
swift99 earned 115 total points
ID: 9838025
I do this all the time between DB2 and Access.  I also use Access to do this between two DB2 databases.

You need to link to your external table from your access database, then the query becomes

insert into destinationTable
select *
from LinkedExternalTable

or alternatively if it is a new table

select *
from linkedExternalTable
into destinationTable
0
 
LVL 2

Author Comment

by:gerryjc
ID: 9920145
Thanks for that swift 99.

Worked for me.

In the end I used a DSN to the external database, linked my tables using that dsn and then used the select statement to create the new tables.

As an added bonus, by using a File dsn, Access appears to store the dsn info internally with the linked tables, meaning I do not need to redistribute a dsn with my app.

Cheers.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to adjust sheet 1 82
Order table with macro 3 75
Magic Software info 18 105
control image tags in a string ? 12 70
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now