Using ODBCLink/SE With ODBC Applications | ODBCLink/SE Reference Manual |
Connecting with ADO’s
1.DECLARE YOUR VARIABLES FOR THE CONNECTION
2.SET THE CONNECTION STRING
3.SET AND OPEN THE CONNECTION TO THE DATABASE/TABLE
4.SET AND OPEN THE RECORDSET FOR THE TABLE
5.USE THE RECORDSET INFORMATION YOU NEED AND PROCESS IT ACCORDINGLY
6.MAKE SURE YOU CLOSE ANY ODJECTS THAT YOU HAVE CREATED WHEN ERRORS OCCUR(OR WHEN EXITING)
1Dim ADORS As ADODB.Recordset Dim ADOCN As ADODB.Connection Dim strConnect As String
2strConnect = "DSN=YOURDSN;UID=YOURUID;PWD=YOURPWD;"
3Set ADOCN = New ADODB.Connection 'Set cursor for the client or server end ADOCN.CursorLocation = adUseClient 'Open Connection
ADOCN.Open strConnect
4'Open the Recordset
Set ADORS = New ADODB.Recordset With ADORS
'Set the cursor type to be used with the recordset
.CursorType = adOpenForwardOnly
.LockType = adLockReadOnly
'Open the recordset with query, connection
.Open "SELECT * FROM TABLE", strConnect End With
5While Not ADORS.EOF
'Insert your query processing code here.
ADORS.MoveNext
Wend
6'close objects and set to nothing ADORS.Close ADOCN.Close
Set ADORS = Nothing Set ADOCN = Nothing
End Sub
| ODBCLink/SE |
54 | ©M.B. Foster Associates Limited |