BUG: RecordsetChangeComplete Does Not Fire on Recordset.Open (192645)



The information in this article applies to:

  • ActiveX Data Objects (ADO) 2.0
  • ActiveX Data Objects (ADO) 2.1 SP2
  • ActiveX Data Objects (ADO) 2.5
  • ActiveX Data Objects (ADO) 2.6
  • ActiveX Data Objects (ADO) 2.7
  • Microsoft Visual Basic Enterprise Edition for Windows 5.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q192645

SYMPTOMS

The RecordsetChangeComplete event of an ADO Recordset does not fire on the Recordset.Open event.

RESOLUTION

You can issue a Recordset.MoveFirst immediately after the Recordset.Open as a workaround, which causes the RecordsetChangeComplete event to fire.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In Visual Basic, open a Standard .exe project.
  2. From the Projects menu, choose References, and then select the Microsoft ActiveX Data Objects Library.
  3. Remove Form1 from the project.
  4. Insert a module (.bas). Add the following code:
          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=<your server name>;Initial Catalog=pubs;", "sa", ""
    
          'rs.open does not fire the RecordsetChangeComplete which it should.
          rs.Open "Select * from authors", cn, adOpenForwardOnly, _
          adLockReadOnly
          'Uncomment the next line to fire the RecordsetChangeEvent
          'rs.MoveFirst 
          DoEvents
          Stop
          'Does fire the RecordsetChangeEvent, which is expected.
          rs.Close
          DoEvents
          End Sub
    					
  5. Insert a class module and name it ADOEvents in the Name property.
  6. Paste the following code in this ADOEvents class module:
          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
    					
  7. Run the project.

Modification Type:MinorLast Reviewed:3/2/2005
Keywords:kbBug kbDatabase kbDSupport KB192645