Article ID: 189365
Article Last Modified on 3/2/2005
Dim oCn As Connection
Dim WithEvents oRs As Recordset
Dim oCm As Command
Private Sub Form_Load()
Set oCn = New Connection
Set oRs = New Recordset
Set oCm = New Command
With oCn
.ConnectionString = "PROVIDER=SQLOLEDB;" & _
"DATA SOURCE=servername;" & _
"Initial Catalog=pubs;" & _
"User Id=username;Password=password"
.Open
End With
With oCm
Set .ActiveConnection = oCn
.CommandText = "select * from authors"
.CommandType = adCmdText
End With
With oRs
Set .ActiveConnection = oCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockBatchOptimistic
.Open oCm
End With
oRs(1) = "something new"
oRs.Update
oRs.UpdateBatch
End Sub
Private Sub oRs_WillChangeRecord _
(ByVal adReason As ADODB.EventReasonEnum, _
ByVal cRecords As Long, _
adStatus As ADODB.EventStatusEnum, _
ByVal pRecordset As ADODB.Recordset)
MsgBox "oRs_WillChangeRecord"
End SubKeywords: kbdatabase kbprb KB189365