473,385 Members | 1,766 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,385 software developers and data experts.

Exporting a Table to ODBC Database

I'm trying to export a table to an ODBC database using a VBA subroutine. I
have tested the ODBC setup manually and it works fine but when I try to do
it with VBA, I get a "connection failed" error. This is the code I'm using.
Can anyone tell me what is wrong with it?

DoCmd.TransferDatabase acExport, "ODBC Database",
"ODBC;DSN=*****;UID=*****;LANGUAGE=us_english; " & "DATABASE=*****",
acTable, "Test", "Test"

Thanks in advance.
Dec 10 '07 #1
9 10179
What kind of database are your exporting to?

Is it a Sql server? Oracle? Sybase? a Mainframe?

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Dec 10 '07 #2
Rich P <rp*****@aol.comwrote in news:475d9c11$0$3575$815e3792
@news.qwest.net:
What kind of database are your exporting to?

Is it a Sql server? Oracle? Sybase? a Mainframe?
MySQL
Dec 10 '07 #3
I am not as familiar with MySql as Sql Server, but I will offer some
suggestions.

First, when you say you want to export a table to your MySql DB I am
interpreting that as you want to write data from one table in an mdb to
a table in the Server DB. If this is the case and you have a working
ODBC connection to the MySql DB, I would try an append query.

If you have a good ODBC connection to the MySql DB, you should be able
to see the desired table in the Access Table window. If you can't see
the MySql table in the Access Table Window, you may not have a good ODBC
connection. I would check this first. Make sure you can see the table
from MySql in Access first. If you can, then try the append query.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Dec 10 '07 #4
Rich P <rp*****@aol.comwrote in news:475da4bc$0$3567$815e3792
@news.qwest.net:
I am not as familiar with MySql as Sql Server, but I will offer some
suggestions.

First, when you say you want to export a table to your MySql DB I am
interpreting that as you want to write data from one table in an mdb to
a table in the Server DB. If this is the case and you have a working
ODBC connection to the MySql DB, I would try an append query.

If you have a good ODBC connection to the MySql DB, you should be able
to see the desired table in the Access Table window. If you can't see
the MySql table in the Access Table Window, you may not have a good ODBC
connection. I would check this first. Make sure you can see the table
from MySql in Access first. If you can, then try the append query.
If I use the manual method (File, Export ...) I can select the ODBC
database and export the table without any problem. The only time I can't
connect is with the Visual Basic code.
Dec 10 '07 #5
In the File menu (top left corner of Access) select

Get External Data

--then select

Linked Tables

When the Link dialog box comes up -- scroll to the bottom of the "Files
Of Type" drop down list. The last selection is "ODBC Databases".
Select that, and it will bring up another dialog with the List of ODBC
connections you have. Select the Machine Datasource tab and look at the
list of ODBC connections (.dsn). Select the dsn for the MySql
connection. If you have a valid ODBC connection to MySql this will
bring up yet another dialog box with a list of tables in the MySql DB
that you can connect to from Access. Scroll through that list and
select your table.

Note: Make sure to check the "Save Password" check box at the bottom
Right corner of this dialog or else you will get an real annoying
Password prompt everytime you try to open this linked table.

Try this and let us know how it works out.

Rich

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Dec 10 '07 #6
Rich P <rp*****@aol.comwrote in news:475daf4a$0$3580$815e3792
@news.qwest.net:
In the File menu (top left corner of Access) select

Get External Data

--then select

Linked Tables

When the Link dialog box comes up -- scroll to the bottom of the "Files
Of Type" drop down list. The last selection is "ODBC Databases".
Select that, and it will bring up another dialog with the List of ODBC
connections you have. Select the Machine Datasource tab and look at the
list of ODBC connections (.dsn). Select the dsn for the MySql
connection. If you have a valid ODBC connection to MySql this will
bring up yet another dialog box with a list of tables in the MySql DB
that you can connect to from Access. Scroll through that list and
select your table.
Yes, this works fine. It's just the VB code that doesn't work.
Dec 11 '07 #7
On 10 Dec 2007 17:23:02 GMT, Bob Sanderson
<ne**@LUVSPAMbobsanderson.comwrote:
>I'm trying to export a table to an ODBC database using a VBA subroutine. I
have tested the ODBC setup manually and it works fine but when I try to do
it with VBA, I get a "connection failed" error. This is the code I'm using.
Can anyone tell me what is wrong with it?

DoCmd.TransferDatabase acExport, "ODBC Database",
"ODBC;DSN=*****;UID=*****;LANGUAGE=us_english; " & "DATABASE=*****",
acTable, "Test", "Test"
You can't use TransferDatabase to send records to a ODBC Database.

Link to the ODBC table, then use a INSERT (Append) Query to transfer
the data from your Access database to the ODBC database.
---
Please Post Any Replies To This Message Back To the Newsgroup.
There are "Lurkers" around who can benefit by our exchange!
Dec 13 '07 #8
Chuck Grimsby <c.*******@worldnet.att.net.invalidwrote in
news:pi********************************@4ax.com:
>You can't use TransferDatabase to send records to a ODBC Database.
I'm confused. Microsoft seems to think that you can. I got the code from
their help files.
Link to the ODBC table, then use a INSERT (Append) Query to transfer
the data from your Access database to the ODBC database.
I'm trying to upload a new table to the ODBC, not append to one.
Dec 13 '07 #9
On 13 Dec 2007 16:41:12 GMT, Bob Sanderson
<ne**@LUVSPAMbobsanderson.comwrote:
>Chuck Grimsby <c.*******@worldnet.att.net.invalidwrote in
news:pi********************************@4ax.com :
>>You can't use TransferDatabase to send records to a ODBC Database.

I'm confused. Microsoft seems to think that you can. I got the code from
their help files.
You mis-read the help file.

---
Please Post Any Replies To This Message Back To the Newsgroup.
There are "Lurkers" around who can benefit by our exchange!
Dec 14 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Angel Cat | last post by:
I'm exporting a large file from a large Production database (SQL). Users are currently updating and inserting new records. Does the export take a snapshot of the data when it starts ? or will...
3
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
0
by: stevenkblack | last post by:
I have a server W2k running DB2 8.1.6. We have two databases one DBDC that holds our user base and QUALITY with all our application data. I have about 8 tables federated on QUALITY looking at the...
5
by: premmehrotra | last post by:
I am using Microsoft Access 2000 and Oracle 9.2.0.5 on Windows 2000. When I export a table from Access to Oracle using ODBC I get error: ORA 972 identifier too long I think the error is because...
3
by: premmehrotra | last post by:
I am using Access 2000 and Oracle 9.2.0.x on a Windows 2000. I have setup Oracle 9.2 ODBC Driver (I have not yet figured how to set Microsoft's Oracle ODBC driver). I am exporting a table from...
1
by: leon | last post by:
Hi all, I have an .mdb file (access database) which has been set to table level locking (i.e. not just records in question, but the whole table). The database is also in sharing mode (ie. not...
1
by: Bruce Lawrence | last post by:
I know this works for Access 97. Not sure about other versions. This will create a DSN to a SQL server in your ODBC connections and then link a table of your choise from that SQL DB to the...
2
by: Maverick | last post by:
If i try to create foxpro table by the following "sql" statment, the C# compiler will only return an error "xxxx not support in non-dbc version". The "index on" command statement return some kind...
2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.