Article ID: 191788
Article Last Modified on 3/2/2005
Control Property Value
------- -------- -----
Label Name lblDSN
Caption DSN
TextBox Name txtDSN
CommandButton Name cmdUseEstablishConnection
Caption Use EstablishConnection
CommandButton Name cmdUseOpenConnection
Caption Use OpenConnection
Option Explicit
Dim WithEvents ConnectionObj As RDO.rdoConnection
Dim Env As RDO.rdoEnvironment
Private Sub cmdUseEstablishConnection_Click()
'Here, we are creating the Object First
Set ConnectionObj = New RDO.rdoConnection
ConnectionObj.Connect = txtDSN
'and then establishing the connection
ConnectionObj.EstablishConnection
End Sub
Private Sub cmdUseOpenConnection_Click()
'Here, we are establishing the connection first
'and then creating the object
Set ConnectionObj = Env.OpenConnection(dsname:="", _
prompt:=rdDriverNoPrompt, Connect:=txtDSN.Text, _
Options:=rdAsyncEnable)
End Sub
Private Sub ConnectionObj_Connect(ByVal ErrorOccurred As Boolean)
MsgBox "We are connected!", vbInformation
End Sub
Private Sub Form_Load()
Set Env = rdoEngine.rdoEnvironments(0)
'This sample is designed to work with the pubs database
'on a local SQL Server. You may change your connect string
'here.
txtDSN = "Driver={SQL Server};Server=(local);" & _
"Database=Pubs;UID=<username>;PWD=<strong password>;"
End Sub
Additional query words: kbVBp400 kbVBp500 kbVBp600 kbdse kbDSupport kbVBp kbRDO
Keywords: kbrdo kbprb KB191788