Help and Support
 

powered byLive Search

PRB: ADO Data Control Events May Generate a Compilation Error

Article ID:222145
Last Review:August 23, 2001
Revision:1.1
This article was previously published under Q222145
On This Page

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.

Back to the top

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.

Back to the top

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.

Back to the top

STATUS

This behavior is by design.

Back to the top

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.

Back to the top

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.

Back to the top

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
257714 (http://support.microsoft.com/kb/257714/EN-US/) FIX: ADO DataControl and DataEnvironment Events Only Work with ADO 2.0

Back to the top


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 Enterprise Edition for Windows 6.0

Back to the top

Keywords: 
kbctrl kbdatabase kbdatabinding kbprb KB222145

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by E-mail, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.