473,383 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

TransferDatabase (ODBC DSN Errors)

2
Dear All,

I have what is likely to be a very small problem for an Access guru, connecting to an ODBC database in VBA in Access 2002. I recieve an error code of 3151 ODBC Connection to 'C:\TempDSN.dsn' Failed.

The code I am using is as follows: -

DoCmd.TransferDatabase acImport, "ODBC Database", _
"ODBC;DSN=C:\TempDSN.dsn;" _
& "DATABASE=" & CurrentDb.Name, acTable, "NODEGEOMETRY"

i have a procedure that searches for applicable databases in a given directory and its sub folders, creates the DSN file, then using the newly created DSN, creates a recordset of the required data and fires it into Access. When I use ->file ->get external data -> import, then select ODBC the data comes into access in about five minutes. The trouble is programmatically it takes upto an hour. One Table has 100,000's of records. (Will eventually load data into SQL)

I want to be able to pull everything in as the menu commands does, but for all files in a folder, inc sub folders, hence the need for TransferDatabase to work from within VBA.

Can anyone help with this issue or know of a more efficient method to import the data.

Thanks muchly in advance

Mogsey
Apr 2 '07 #1
3 5521
MMcCarthy
14,534 Expert Mod 8TB
ODBC connections don't work based on file path but just the DSN name.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferDatabase acImport, "ODBC Database", _
  2. "ODBC;DSN=TempDSN;" _
  3. & "DATABASE=" & CurrentDb.Name, acTable, "NODEGEOMETRY"
The code for an odbc connection is as follows:
Expand|Select|Wrap|Line Numbers
  1. ODBC;DSN=TempDSN;APP=Microsoft® Access;DATABASE=DatabaseName;TABLE=TableName
Apr 2 '07 #2
Mogsey
2
Hi M,

I'm still getting a 3151 error, ODBC-Connection to 'Temp.DSN' failed.

Do i have to register the dsn anywhere?

Thanks

Mogsey
Apr 4 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Hi M,

I'm still getting a 3151 error, ODBC-Connection to 'Temp.DSN' failed.

Do i have to register the dsn anywhere?

Thanks

Mogsey
You need to create the DSN connection and it's not Temp.DSN. I got the name TempDSN from your code.

The easiest way to create the DSN connection is to open access and go to Get External Data - Link files. This will open a dialog window. Change the filetype to odbc databases and this will open the connection window. You can create a new DSN connection from here.

Mary
Apr 4 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Steve | last post by:
I normally use MySQL with PHP, but I'm delving into connecting to Access with ODBC (for a database that I already have set up at work), and I'm running into a couple of errors. I'm just trying to...
2
by: Pachydermitis | last post by:
Hi all, I am trying to use transferdatabase to link tables to a shared backend. If someone is already using the back end, transferdatabase tries to lock the table and causes an error. Is there...
2
by: PeteCresswell | last post by:
My code for DoCmd.TransferDatabase stopped working after applying the update in question. Seems like the last argument (optional: SaveLogInID) can no longer be specified when...
14
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought...
1
by: Danny J. Lesandrini | last post by:
Does anyone know if it's possible to use TransferDatabase to export data to MySQL? If not, how would one go about it? Below is the code I tried to use, but it doesn't work. sTable = "tblLead"...
0
by: astro | last post by:
I'm trying to copy some ODBC linked tables from one access2k mdb to another. This is an example of the code i'm using: DoCmd.TransferDatabase acExport, "Microsoft Access", (strPath & strTemp),...
4
by: Phil Latio | last post by:
Scenario is: We have an intranet on which a Helpdesk application can be accessed. Data input into the Helpdesk is stored in a Access 2000 database, held on a server. This is great, works fine,...
9
by: Greg Strong | last post by:
Hello All, What is the maximum length of an ODBC pass through query? Things work fine with the code except when I try to create a view which is pretty complex in Oracle. I'm using a DSN...
16
by: network-admin | last post by:
We have Problems with Access query on Oracle 10g Database with ODBC Connection. The Query_1 is such as select * from xtable where ycolumn <"S" Result = ODBC Faild...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.