ODBC Conenction Programmatically

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
T

Todd Huttenstine

Hey guys

Using ODBC, it is possible to set up a connection to a
database. Instead of having to do this manually for
multiple computers, I would like to be able to run a code
that will do it automatically. For instance if I wanted
to setup a database connection to file C:\test.mdb, I
would open up the ODBC managaer and then type in a
description, navigate to the source, etc.. How do I write
code that will set up a system database connection to a
file called test.mdb located on C:\?


Thanks
Todd Huttenstine
 
Turn on the macro recorder and do it manually. Then turn it off and look at
the code.
 
How can you access the ODBC manager from within Excel? I
dont think you can...
 
Data=>Get External Data

or

Data => Import External Data

Depending on version of Excel.
 
Todd,

You can use the prompt against the ODBC provider for OLEDB.

Set con = New ADODB.Connection
con.ConnectionString = ConnectionString
con.Provider = "MSDASQL"
con.Properties("Prompt") = adPromptAlways
con.Open
str = con.Properties("Extended Properties")



This is the code I use in the Query Editor on my website.


--
Rob van Gelder - http://www.vangelder.co.nz/excel


-----Original Message-----
From: Todd Huttenstine [mailto:[email protected]]
Posted At: Friday, 31 December 2004 5:33 a.m.
Posted To: microsoft.public.excel.programming
Conversation: ODBC Conenction Programmatically
Subject: ODBC Conenction Programmatically

Hey guys

Using ODBC, it is possible to set up a connection to a
database. Instead of having to do this manually for
multiple computers, I would like to be able to run a code
that will do it automatically. For instance if I wanted
to setup a database connection to file C:\test.mdb, I
would open up the ODBC managaer and then type in a
description, navigate to the source, etc.. How do I write
code that will set up a system database connection to a
file called test.mdb located on C:\?


Thanks
Todd Huttenstine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top