BUG: RecordsetChangeComplete Does Not Fire on Recordset.OpenID: Q192645
|
The RecordsetChangeComplete event of an ADO Recordset does not fire on the Recordset.Open event.
You can issue a Recordset.MoveFirst immediately after the Recordset.Open as a workaround, which causes the RecordsetChangeComplete event to fire.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
Sub main()
Dim myADOEvents As New ADOEvents
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set myADOEvents.rsEvent = rs
cn.Provider = "sqloledb"
cn.Open "Data Source=zjason2;Initial Catalog=pubs;", "sa", ""
'rs.open does not fire the RecordsetChangeComplete which it should.
rs.Open "Select * from authors", cn, adOpenForwardOnly, _
adLockReadOnly
'rs.MoveFirst 'if you uncomment this line than the
'RecordsetChangeEvent.
DoEvents
Stop
'Does fire the RecordsetChangeEvent, which is expected.
rs.Close
DoEvents
End Sub
Public WithEvents rsEvent As ADODB.Recordset
Private Sub rsEvent_RecordsetChangeComplete(ByVal adReason As
ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As
ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Debug.Print "RecordsetChangeComplete"
End Sub
Additional query words: kbADO200bug kbVBP500 kbVBP600
Keywords : kbADO200bug kbVBp500 kbVBp600
Version : WINDOWS:2.0,5.0,6.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: May 17, 1999