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
Solved

IS this possible in Access/VB

Posted on 2003-11-26
9
547 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
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.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

809 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