Microsoft KB Archive/257731

= BUG: Error Message "Rows Must Be Released" with SQLOLEDB and ADO Recordset Events =

Article ID: 257731

Article Last Modified on 12/3/2003

-

APPLIES TO


 * Microsoft Data Access Components 2.1
 * Microsoft Data Access Components 2.5
 * Microsoft Data Access Components 2.6
 * Microsoft Data Access Components 2.7
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q257731



SYMPTOMS
If a user opens an ActiveX Data Object (ADO) recordset by using the OLE DB Provider for SQL Server, sets the CursorLocation property to adUseServer, uses the WithEvents keyword, updates the same record more than once, and then executes a Move method such as MoveNext, the following error message appears

in MDAC versions 2.5 and later:

80040e25: Row handles must be released before new ones can be obtained

in prior MDAC versions:

All HROWs must be released before new ones can be obtained



RESOLUTION
This error message can be avoided in one of the following ways:
 * Using a CursorLocation property of adUseClient.

-or-


 * Implementing code that moves off the changed record after each Update (for example, a MoveNext and MovePrevious method pair).

-or-


 * Executing the Requery method of the Recordset after each Update.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a new Visual Basic Standard EXE project in Visual Basic. Form1 is created by default. Set a reference to Microsoft ActiveX Data Objects (ADO).  Enter the following code into Form1's Code Window. Modify the ConnectionString to connect to your SQL Server:

Note You must change User ID= and Password= to the correct values before you run this code. Make sure that the User ID has the appropriate permissions to perform this operation on the database. Option Explicit Dim WithEvents rs As ADODB.Recordset

Private Sub Form_Load Dim cn As ADODB.Connection Set cn = New ADODB.Connection With cn   .ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID= ;Password= ;Initial Catalog=pubs;Data Source=servername;" .CursorLocation = adUseServer .Open End With Set rs = New ADODB.Recordset With rs Set rs.ActiveConnection = cn    .CursorLocation = adUseServer .CursorType = adOpenDynamic .Open "select * from Authors", cn, adOpenDynamic, adLockOptimistic .Fields("au_lname").Value = "footfoot1" .Update .Fields("au_lname").Value = "footfoot2" .Update .MoveNext End With End Sub  Run the code. Note the error raised on the .MoveNext method.

Additional query words: sp4 error 80040e25

Keywords: kbbug kbdatabase kbpending KB257731

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.