Microsoft KB Archive/195638

= PRB: IRowsetNotify Error with ADO Data Control and ADO Recordset =

Article ID: 195638

Article Last Modified on 3/14/2005

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.1 Service Pack 2
 * Microsoft ActiveX Data Objects 2.5
 * Microsoft ActiveX Data Objects 2.6
 * Microsoft ActiveX Data Objects 2.7

-



This article was previously published under Q195638



SYMPTOMS
Prior to MDAC version 2.5, when you manipulate methods of the ADO Data Control's Recordset property through code, or when you manipulate an ADO Recordset object that has controls bound to it, you receive the following error message:

Run-time error '-2147217888 (80040e20)':

Provider called a method from IRowsetNotify in the consumer and the

method has not yet returned.

In MDAC 2.5 or later, the error message appears as follows:

Consumer's event handler called a non-reentrant method in the provider.



RESOLUTION
 Use a client-side cursor instead of a server-side cursor.

-or-  Add a call to the Recordset's Move method immediately prior to the offending line. For example: ADODC1.Recordset.Move 0

Resolution number 2 is the workaround discussed in the "More Information" section below. -or-

 Microsoft Visual Basic 6.0 Service Pack 3 has been found to resolve this error in some scenarios.

For information on installing Service Pack 3 of Microsoft Visual Basic, please see the following article in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why





STATUS
The following are two methods to resolve this issue:  Method A is resolved using MDAC 2.5. Method B still occurs under MDAC 2.5, but the error text is as follows:

Consumer's event handler called a non-reentrant method in the provider.

The error number is the same.</li></ul>

<div class="moreinformation_section">

MORE INFORMATION
The ADO data control and the ADO Recordset object sometimes do not respond correctly to IRowsetNotify events raised by the data provider. There are currently three known methods to generate this error. The workaround described above works in each of these cases. It should also be tried in any unconfirmed cases.

NOTES:
 * 1) The error does not appear when using client-side cursors, only when using server-side cursors (ServerLocation = adUseServer). However, it may not always be feasible or desirable to use client-side cursors.
 * 2) Though the article demonstrates the error using the Microsoft OLE DB Provider for Jet, the error is not limited to this provider.
 * 3) Though the article demonstrates the error using the ADO Data Control, the first two methods also can cause the error when using an ADO Recordset object bound as the DataSource of the controls.

Method A - Adding a Record
 Create a Standard EXE project in Visual Basic. Form1 is created by default.</li>  Use the Projects | Components dialog to register the following controls with the project: <pre class="fixed_text">Microsoft ADO Data Control 6.0 (OLEDB) Microsoft DataList Controls 6.0 (OLEDB) </li>  On the default form (Form1), add the following controls: ADO Data Control Name = ADODC1 CursorLocation = adUseServer CursorType = adOpenKeyset LockType = adLockOptimistic ConnectString = Provider=Microsoft.Jet.OLEDB.3.51; Data Source=nwind.mdb RecordSource = Orders

ADO Data Control Name = ADODC2 CursorLocation = adUseServer CursorType = adOpenKeyset LockType = adLockOptimistic ConnectString = Provider=Microsoft.Jet.OLEDB.3.51; Data Source=nwind.mdb RecordSource = Customers

ADO Data Combo Name = DataCombo1 DataSource = ADODC1 DataField = CustomerID RowSource = ADODC2 ListField = CompanyName BoundColumn = CustomerID

Command Button Name = cmdAddNew Caption = Add New

Command Button Name = cmdUpdate Caption = Update

</li> Fix the connect string property on the ADO Data Controls to point either to NWIND or to the database of your choice on your system.</li>  Add the following code to the form: Private Sub cmdAddNew_Click ADODC1.Recordset.AddNew End Sub

Private Sub cmdUpdate_Click ' ADODC1.Recordset.Move 0 ADODC1.Recordset.Update End Sub

</li> Run the project, click cmdAddNew, and select a customer from the Data Combo.</li> Click cmdUpdate and note that you receive the error.</li> Uncomment the first line in cmdUpdate_Click and redo steps 6-9. The error does not occur.</li></ol>

NOTES:
 * 1) The error also does not appear if you use a text box or the standard Combo box to select customer codes from, indicating the problem may be with the Data Combo.
 * 2) The error can also be reproduced using a standard ADO Recordset as the DataSource of the DataCombo. However, the other two methods described below do not use the Data Combo at all.

Method B - Updating a Record
 Create a Standard EXE project in Visual Basic. Form1 is created by default.</li>  Use the Projects | Components dialog to register the following control with the project: <pre class="fixed_text">Microsoft ADO Data Control 6.0 (OLEDB) </li> Add an MDI form to the project (MDIForm1).</li> On the MDI form, add a Picture Box control, and, in the Picture Box control, add a CommandButton (cmdBadUpdate).</li>  Add the following code to the MDI form: Private Sub MDIForm_Load Form1.Show End Sub

Private Sub cmdBadUpdate_Click ' MDIForm1.ActiveForm.ADODC1.Recordset.Move 0 MDIForm1.ActiveForm.ADODC1.Recordset.Update End Sub

</li> On the default form (Form1), set the MDIChild property to True.</li> <li> On the default form (Form1), add the following controls: ADO Data Control Name = ADODC1 CursorLocation = adUseServer CursorType = adOpenKeyset LockType = adLockOptimistic ConnectString = Provider=Microsoft.Jet.OLEDB.3.51; Data Source=nwind.mdb RecordSource = Orders

Text Box Name = Text1 DataSource = ADODC1 DataField = CustomerID

Text Box Name = Text2 DataSource = ADODC1 DataField = OrderDate

Text Box Name = Text3 DataSource = ADODC1 DataField = ShippedDate

Command Button Name = cmdUpdate Caption = Update

</li> <li>Fix the connect string property on the ADO Data Control to point either to NWIND or to the database of your choice on your system.</li> <li> Add the following code to Form1: Private Sub cmdUpdate_Click ADODC1.Recordset.Update End Sub

</li> <li>Run the project and verify that you see an order.</li> <li>Edit both date fields (just one won't do it).</li> <li>Click the CommandButton in the MDI form. You will get the error.</li> <li>Repeat steps 10-12, but click on the "Update" button on Form1. The error does not occur.</li> <li>Uncomment the first line in cmdBadUpdate_Click on the MDI form and repeat steps 10-12. The error does not occur.

NOTE: You can also reproduce the error if you replace the DataSource of the three text boxes with a reference to an ADO Recordset object.</li></ol>

Method C - Deleting a Record
Microsoft does not have a consistently reproducible sample for this error. However, it can occur when you have a Data List Combo box bound to two ADO Data controls. The error occurs when you have code that deletes a record from the Data control that is bound to the DataList Combo box's DataSource property. The error only happens if the table has one record and the Data control is using server-side cursors.

The workarounds are the same as the other two cases. Also, unlike the other two cases, using an ADO Recordset does not cause the error to occur.

<div class="references_section">