Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Building an ADO connection string 3

Status
Not open for further replies.

Schroeder

MIS
Sep 25, 2001
382
US
I have just started moving from DAO to ADO and I'm unclear as to how to build connection strings. A book I'm looking at shows a connection string for an Access 2000 database. That works fine for me but I also want to connect to a database via a different ODBC provider installed on my machine. How do I determine the proper syntax for the connection string? I poked around in ODBC Data Sources in the Control Panel but can't find anything that looks like a clue for me.
 
I've found the following website to very helpful with regards to building connection strings:


Lots of samples for various providers. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
I have always dropped an ADODC Control on a form and then use the wizard to build the default connection string. After that I just copy the string and work with it from there. Just a thought. If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Thanks for the help. CC, I'm using an ODBC driver provided by Transoft and I didn't see that on the link. It was, however, very informative regarding the different types of connections that can be made. This is a foggy subject for me.
Using the ADODC control's Build function got me started on creating the string. Oddly, before it worked properly, I had to modify it to look a little more like a connection string I used to use for the same data source with DAO.

It seems strange to me that this is something that can't be found more easily. If the ADODC control's Build wizard can generate a string, there must be some way of finding that string without jumping through hoops or resorting to wrote memorization.
 
Hi

Another possibility is to goto explorer, make an new empty file called whatever.udl
A double click in this file will bring up the data link properties dialog where you can select provider, database, server and so on and so forth. When done, click ok and copy the connection string from the file. Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
I don't remember where I found this code, but I use it all the time. Copy it into notepad and save it with a .vbs (VB Script) extension. Anytime you need a connection string to an OLEDB data source double-click the file and it opens a dialog that walks you through creating the string, with a screen at the end that you can copy the string from at the end.

Dim oDataLinks, sRetVal
set oDataLinks = CreateObject("DataLinks")
On Error Resume Next
sRetVal = oDataLinks.PromptNew
On Error Goto 0
If Not IsEmpty(sRetVal) Then
InputBox "Your Connection String Is Listed Below", "OLEDB Connection String", sRetVal
End If
Set oDataLinks = Nothing
 
Schroeder,

I'm working on setting up a connection with a Transoft driver. Could you post the connection string that you used? I cannot find any information anywhere on the web about it. Thank you!
 
Provider=MSDASQL.1;Data Source=DSN;GR_UID=[username];GR_PWD=[password];

I'm using a DSN. The trouble I was having was with the username and password parts. If I let the ADODC wizard build the string it said something like "...;username=;password=;", or whatever. That needed to be changed to "...;GR_UID=;GR_PWD;"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top