Microsoft KB Archive/222145

From BetaArchive Wiki

Article ID: 222145

Article Last Modified on 8/23/2001



APPLIES TO

  • Microsoft ActiveX Data Objects 2.1
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft ActiveX Data Objects 2.6
  • Microsoft ActiveX Data Objects 2.7
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 6.0 Enterprise Edition



This article was previously published under Q222145

SYMPTOMS

If you are using the ADO Data Control events in a Visual Basic 6.0 project and you reference ADO 2.1 or later, the following compile error occurs:

Compile Error:
Procedure declaration does not match description of event or procedure having the same name.

The following ADO Data Control Events generate the error if used:

EndOfRecordset
FieldChangeComplete
MoveComplete
RecordChangeComplete
RecordsetChangeComplete
WillChangeField
WillChangeRecord
WillChangeRecordset
WillMove

The above events all use the ADODB.Recordset parameter within the declaration.

For example: The ADO Data Control event WillMove declaration is:

Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset 
                

NOTE: If no ADO Data Control events are used in the project, no errors will occur.

CAUSE

The interfaces in ADO 2.1 and later have been changed from ADO 2.0. There is no issue with interface changes unless a control is compiled using an older version of ADO. This is the case with the ADO data control. See the "More Information" section for details.

RESOLUTION

To make the ADO Data Control events work with ADO 2.1 or later, the declaration of the event has to be changed to include:

ADODB.Recordset20
Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset20)
                

Please note that the "20" that has been added to ADODB.Recordset in the pRecordset argument.

STATUS

This behavior is by design.

MORE INFORMATION

The ADO Data control is part of Visual Basic 6.0 and was compiled using MDAC 2.0, which was included with Visual Basic 6.0. To use the ADO data control with MDAC 2.1 or later, make the changes to the event declarations as noted in the "Resolution" section of this article.

Steps to Reproduce Behavior

  1. Start Visual Basic 6.0 and select Standard EXE project. Form1 is created by default.
  2. Set the project reference to Microsoft ActiveX Data Objects 2.0 Library.
  3. Add Microsoft ADO Data Control 6.0 (OLEDB) to the project components.
  4. Place the following controls on the default form:
    • ADO Data Control.
    • Text Box.


  5. Bind the ADO Data Control to an Access Database (Biblio.mdb) using Microsoft JET OLEDB 3.51 provider.
  6. Set the RecordSource of the ADO Data Control to Authors table.
  7. Set the DataSource of the Text box to ADODC1 and the DataField to Author.
  8. Add code for a message box in the ADODC1 WillMove event:

    MsgBox "Hello..."
                        
  9. Run the project and note that there are no errors.
  10. Change the project reference to Microsoft ActiveX Data Objects 2.1 or later Library.
  11. Re-run the project and note the Compilation error.


REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

257714 FIX: ADO DataControl and DataEnvironment Events Only Work with ADO 2.0


Keywords: kbdatabinding kbdatabase kbprb kbctrl KB222145