Solved

IS this possible in Access/VB

Posted on 2003-11-26
9
551 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 116
firstswap challenge 20 87
Q2. How to run DAX query from SSMS. I don’t see any DAX query type. 1 71
Java array 10 64
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

726 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