Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q257731

↑ Back to the top


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

↑ Back to the top


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.

↑ Back to the top


Status

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

↑ Back to the top


More information

Steps to Reproduce Behavior

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

    Note You must change User ID=<username> and Password=<strong 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=<username>;Password=<strong 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
  4. Run the code. Note the error raised on the .MoveNext method.

↑ Back to the top


Keywords: KB257731, kbpending, kbdatabase, kbbug

↑ Back to the top

Article Info
Article ID : 257731
Revision : 5
Created on : 12/3/2003
Published on : 12/3/2003
Exists online : False
Views : 340