PRB: WillChangeRecord Event Does Not Fire on UpdateID: Q189365
|
When issuing a Recordset.Update, the WillChangeRecord event does not fire.
Whether this event fires or not depends on the type of cursor opened. If the locking schema for the cursor is adLockBatchOptimistic then this event will not fire on Recordset.Update; instead it fires on UpdateBatch.
This behavior is by design.
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=matthofa;" & _
"Initial Catalog=pubs;" & _
"User Id=sa;Password="
.Open
End With
With oCm
Set .ActiveConnection = oCn
.CommandText = "select * from authors"
.CommandType = adCmdText
End With
With oRs
Set .ActiveConnection = oCn<BR/>
.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 Sub
Additional query words: kbnokeyword kbado200 kbMDAC200 kbVBp600
Keywords : kbnokeyword kbADO200 kbVBp600 kbMDAC200
Version : WINDOWS:2.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 27, 1999