BUG: WillChangeRecordset Event Not Executed (191455)



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

This article was previously published under Q191455

SYMPTOMS

When the Close method of an ActiveX Data Objects (ADO) RecordSet object is called, the WillChangeRecordset event does not fire. The documentation for the WillChangeRecordset event states, in error, that this event fires when closing the RecordSet.

The documentation for ADO 2.5 and later states that the WillChangeRecordset event may fire on the Requery and Open operations. At the same time, however, adRsnClose is still listed as a possible reason for the WillChangeRecordset event.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a Standard EXE Project in Visual Basic.
  2. From Project menu, choose Components and then select "Microsoft ActiveX Data Objects Library".
  3. Add a TextBox control and Command Button to the form.
  4. Add the following code to the General Declarations of the form:

    Note You must change UID=<username> and PWD=<strong password> to the correct values before you run this code. Make sure that UID has the appropriate permissions to perform this operation.on the database.
       Dim WithEvents rst As ADODB.Recordset
       Dim cn As New ADODB.Connection
    
       Private Sub Form_Load()
       With cn
       .CursorLocation = adUseClient
       .Open "dsn=pubs;uid=<username>;pwd=<strong password>;"
       End With
    
       Set rst = cn.Execute("Select * from Authors")   
       Set Text1.DataSource = rst
       Text1.DataField = "au_lname"
    
       End Sub
    
       Private Sub rst_WillChangeRecordset(ByVal adReason As _
         ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, _
         ByVal pRecordset As ADODB.Recordset)
         Debug.Print "ADO WillChangeRecordset"
    
       End Sub
    
       Private Sub Command1_Click()
         Debug.Print "About to Close"
    
         rst.Close
    
         Debug.Print "Close complete"
         Unload Me
    
       End Sub
    					
Note The preceding code sample assumes that you have a DSN that points to a valid SQL Server and the Pubs database.
  • Press the F5 key to run the application and then click the Command Button. Notice that in the Debug Window the "ADO WillChangeRecordset" is not printed after "About to Close" prints.
Note It is printed immediately after the Text box's DataField is assigned.

REFERENCES

For additional information about ActiveX Data Objects (ADO) events, please refer to the Data Access Software Development Kit (DASDK), Microsoft Data Access Components (MDAC) or the Visual Studio 6.0 documentation.

For the latest ActiveX Data Objects (ADO) information and updates please see the following URL:

Modification Type:MinorLast Reviewed:3/2/2005
Keywords:kbBug kbDatabase kbpending KB191455