Public objRS As ADODB.Recordset
Public objCon As ADODB.Connection
Public getConString As String
Public Sub GetCon()
If objCon.State = adStateOpen Then objCon.Close
With objCon
.ConnectionString = getConString
.Open
End With
End Sub
Sub GetRecordSet(strSource As String)
If objRS.State = adStateOpen Then objRS.Close 'If the database is open close before getting a new recordset
'On Error GoTo Errorhandler 'I take care of eventual errors
With objRS
.ActiveConnection = objCon
'.CursorLocation = adUseClient
.CursorType = 3 'Move the cursor in any direction and bookmarkable
.LockType = 1 'Editing is possible
.Source = strSource 'What Recordset to get
.Open
'.MoveFirst
End With
End Sub
-------------------------------------------------------------------
Set objCon = New ADODB.Connection
Set objRS = New ADODB.Recordset
getConString = "Provider=SQLOLEDB.1" & _
";Persist Security Info=False" & _
";User ID=sa" & _
";Password=csm@csm" & _
";Initial Catalog=xiazaijilu" & _
";Data Source=" & _
";Network Library=" 'DBMSSOCN"