Article ID: 166392
Article Last Modified on 7/13/2004
'Microsoft SQL Server ODBC Driver example
cnstr = "driver={SQL Server};server=myserver;" & _
"database=pubs;uid=<username>;pwd=<strong password>"
cn.Connect = cnstr
'Microsoft Access ODBC Driver example (version 2.x)
cnstr = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=c:\program files\devstudio\vb\biblio.mdb;" & _
"Uid=Admin; Pwd="
cn.Connect = cnstr
'Microsoft ODBC Driver for Oracle example
cnstr = "Driver={Microsoft ODBC Driver for Oracle};" & _
"Server=OracleServer.world; Uid=demo; Pwd=demo"
' Note that 1.0 version of the Microsoft Oracle driver used
' "ConnectString" notation instead of "Server"
"{SQL Server}"
The connect string contains a series of semi-colon-delimited arguments as defined by the ODBC interface - including the ODBC driver itself. That is, all ODBC drivers have specific argument requirements so you should consult the documentation included with the driver for specific information. This connect string is passed to the ODBC API SQLDriverConnect function along with the hEnv for the associated rdoEnvironment object.
Private Sub Command1_Click()
Dim Cn As New rdoConnection 'creatable rdoConnection
Dim Qr As New rdoQuery 'creatable rdoQuery
Dim Rs As rdoResultset 'pointer to rdoResultset
Dim cnstr As String 'hold connection info
cnstr = "driver={SQL Server};server=myserver;" & _
"database=pubs;uid=<username>;pwd=<strong password>"
Cn.Connect = cnstr
Cn.CursorDriver = rdUseClientBatch
Cn.EstablishConnection Prompt:=rdDriverNoPrompt
Set Qr.ActiveConnection = Cn
Qr.SQL = "Select * From Authors"
Set Rs = Qr.OpenResultset(Type:=rdOpenKeyset, _
LockType:=rdConcurBatch)
Debug.Print Rs(0), Rs(1), Rs(2)
End Sub
Guide to Building Client Server Applications in Visual Basic (Enterprise)
Part 3: Data Access Options
Using Remote Data Objects and the Remote Data Control
Establishing an RDO Connection
Providing Connection Strings to RDO
Additional query words: kbVBp500 kbVBp600 kbdse kbDSupport kbVBp kbODBC KbRDO kbDriver kbDatabase kbSQL kbOracle
Keywords: kbhowto KB166392