Help and Support
 

powered byLive Search

PRB: IRowsetNotify Error with ADO Data Control and ADO Recordset

Article ID:195638
Last Review:March 14, 2005
Revision:1.2
This article was previously published under Q195638
On This Page

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.

Back to the top

RESOLUTION

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

-or-
2.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-

3.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 (http://support.microsoft.com/kb/194022/EN-US/) INFO: Visual Studio 6.0 Service Packs, What, Where, Why

Back to the top

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.

Back to the top

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.

Back to the top

Method A - Adding a Record

1.Create a Standard EXE project in Visual Basic. Form1 is created by default.
2.Use the Projects | Components dialog to register the following controls with the project:
Microsoft ADO Data Control 6.0 (OLEDB)
Microsoft DataList Controls 6.0 (OLEDB)
					
3.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

					
4.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.
5.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

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

Back to the top

Method B - Updating a Record

1.Create a Standard EXE project in Visual Basic. Form1 is created by default.
2.Use the Projects | Components dialog to register the following control with the project:
Microsoft ADO Data Control 6.0 (OLEDB)
					
3.Add an MDI form to the project (MDIForm1).
4.On the MDI form, add a Picture Box control, and, in the Picture Box control, add a CommandButton (cmdBadUpdate).
5.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

					
6.On the default form (Form1), set the MDIChild property to True.
7.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

					
8.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.
9.Add the following code to Form1:
      Private Sub cmdUpdate_Click()
        ADODC1.Recordset.Update
      End Sub

					
10.Run the project and verify that you see an order.
11.Edit both date fields (just one won't do it).
12.Click the CommandButton in the MDI form. You will get the error.
13.Repeat steps 10-12, but click on the "Update" button on Form1. The error does not occur.
14.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.

Back to the top

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.

Back to the top

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
288772 (http://support.microsoft.com/kb/288772/EN-US/) BUG: Error Message Received When You Use the DTPicker to Update Table

Back to the top


APPLIES TO
Microsoft Visual Basic 6.0 Professional Edition
Microsoft Visual Basic Enterprise Edition for Windows 6.0
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

Back to the top

Keywords: 
kbdatabinding kbexcel123quattro kbprb KB195638

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.