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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

odbc connection strings

Status
Not open for further replies.

jonnyk

Programmer
Jan 11, 2001
19
GB
I have successfully attached to SQL server using connection strings, but am having difficulty with the syntax to connect to a database using ODBC. I do not want to be reliant on DSN's.
 
Try something like this...

Public cndb As ADODB.Connection 'global connection variable
Public dbsCurrent As Database 'Current database

gsServerName = "XXXX"
gsUserIDName = "XXXX"
gsPassword = "XXXX"

Set cndb = New ADODB.Connection
gsSQL = "Provider=MSDAORA.1"
gsSQL = gstrSQL & ";Data Source=" & gstrServerName
gsSQL = gstrSQL & ";User ID=" & gstrUserIDName
gsSQL = gstrSQL & ";Password=" & gstrPassword
cndb.ConnectionString = gstrSQL
cndb.CursorLocation = adUseServer
cndb.Open
If cndb.State <> adStateOpen Then
MsgBox &quot;Unable to connect to Oracle database&quot;
End
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top