PRB: ADO Data Control Events May Generate a Compilation Error

ID: Q222145


The information in this article applies to:


SYMPTOMS

If you are using the ADO Data Control events in a Visual Basic 6.0 project and you reference ADO 2.1, 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 ADO 2.1 interfaces 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, 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. If you use the ADO data control with MDAC 2.1, you have to keep the project reference pointing to ADO 2.0 because the interfaces changed from 2.0 to 2.1, which is why you see a compile error.

To be able to use the ADO data control with ADO 2.1 would require that the data control be re-compiled. Because the data control is a Visual Basic feature, it won't be re-compiled until the next release of Visual Basic (ADO Data Control doesn't ship with the MDAC stack.) Any time ADO has new added features, the interfaces change and any control built with an older version of ADO only has access to the older interfaces until re-compiled with the newer interfaces.

If you have a machine that had ADO 2.0 and you installed ADO 2.1, you are using ADO 2.1 but you only get the 2.0 interfaces with the ADO Data Control. As a result, what you are going to have is ADO 2.0 type library and ADO 2.1 Object library although the project references still shows both Microsoft ActiveX Data Objects 2.0 Library and Microsoft ActiveX Data Objects 2.1 Library.

Also notice that the file being referenced with ADO 2.0 is:

(C:\Program Files\Common Files\system\ado\msado20.tlb)

while it is (C:\Program Files\Common Files\system\ado\msado15.dll) with ADO2.1.

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:


  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:


  9. 
    MsgBox "Hello..." 
  10. Run the project and note that there are no errors.


  11. Change the project reference to Microsoft ActiveX Data Objects 2.1 Library.



  12. Re-run the project and note the Compilation error.


© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Hussein Abuthuraya, Microsoft Corporation

Additional query words:


Keywords          : kbADO200 kbADO210 kbVBp600 
Version           : WINDOWS:2.1,6.0
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 4, 1999