Microsoft KB Archive/222145

= PRB: ADO Data Control Events May Generate a Compilation Error =

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
 Start Visual Basic 6.0 and select Standard EXE project. Form1 is created by default. Set the project reference to Microsoft ActiveX Data Objects 2.0 Library. Add Microsoft ADO Data Control 6.0 (OLEDB) to the project components. Place the following controls on the default form:  ADO Data Control.</li> Text Box.</li></ul>

</li> Bind the ADO Data Control to an Access Database (Biblio.mdb) using Microsoft JET OLEDB 3.51 provider.</li> Set the RecordSource of the ADO Data Control to Authors table.</li> Set the DataSource of the Text box to ADODC1 and the DataField to Author.</li>  Add code for a message box in the ADODC1 WillMove event: MsgBox "Hello..." </li> Run the project and note that there are no errors.</li> Change the project reference to Microsoft ActiveX Data Objects 2.1 or later Library.

</li> Re-run the project and note the Compilation error.</li></ol>

<div class="references_section">