Microsoft KB Archive/236624

= FIX: Navigating Through an ADO Recordset Clone May Generate Error -2147217885 =

Article ID: 236624

Article Last Modified on 11/5/2003

-

APPLIES TO


 * Microsoft ActiveX Data Objects 2.0
 * Microsoft ActiveX Data Objects 2.01
 * Microsoft ActiveX Data Objects 2.1
 * Microsoft ActiveX Data Objects 2.1 Service Pack 1
 * Microsoft ActiveX Data Objects 2.1 Service Pack 2

-



This article was previously published under Q236624



SYMPTOMS
Performing the following steps on a disconnected ADO recordset:
 * 1) Sort the recordset.
 * 2) Delete a record from the recordset.
 * 3) Clone the recordset.
 * 4) Navigate through the recordset Clone using the MoveNext method.

may generate the following error:

Run-time error '-2147217885(80040e23)': A given HROW referred to a hard- or soft-deleted row

Performing the following steps on a disconnected ADO recordset may also generate error -2147217885:
 * 1) Delete a record from the recordset.
 * 2) Clone the recordset.
 * 3) Filter the recordset Clone.
 * 4) Navigate through the recordset Clone using the MoveNext method.



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

This problem has been fixed in MDAC 2.5 and later.



Steps to Reproduce Behavior
The following example uses the Pubs database that comes with SQL Server.  Create a new Visual Basic project. Form1 is created by default. Add a Project Reference to Microsoft ActiveX Data Objects Library 2.0 or Microsoft ActiveX Data Objects Library 2.1. Add a command button to Form1. Command1 is created by default.  Paste the following code into the General Declaration section of Form1. Replace sql_server_name with the name of your SQL Server.

Note You must change User ID  and password  to the correct values before you run this code. Make sure that User ID has the appropriate permissions to perform this operation on the database. Dim rs As ADODB.Recordset Dim rsClone As ADODB.Recordset Dim Cn As ADODB.Connection

Private Sub Command1_Click

Set Cn = New ADODB.Connection Set rs = New ADODB.Recordset

' Open the connection Cn.Open "Provider=SQLOLEDB;Data Source=sql_server_name;User ID=;Password=;Initial Catalog=Pubs;"

'Open a disconnected ADO recordset With rs   .CursorLocation = adUseClient .LockType = adLockBatchOptimistic .Open "SELECT * FROM Titles", Cn

'Disconnect the recordset Set .ActiveConnection = Nothing Cn.Close Set Cn = Nothing End With

'Perform the Sort/Delete/Clone/MoveNext steps, to generate the error With rs   ' Sort the recordset .Sort = "pub_id" .MoveLast ' Delete current record in the recordset .Delete ' Take a clone of the recordset Set rsClone = .Clone End With

' Filter the recordset Clone rsClone.Filter = "pub_id <= 1000"

' Navigate through the cloned recordset With rsClone Do While Not .EOF ' Error occurs on this next line .MoveNext Loop End With

' Clean up rsClone.Close Set rsClone = Nothing rs.Close Set rs = Nothing

End Sub </li> Run the project. You may get error -2147217885.</li>  Comment out either of the following lines of code: .Sort = "pub_id" -or- rsClone.Filter = "pub_id <= 1000" </li> Run the project. You should now be able to run without receiving error -2147217885.</li></ol>

Additional query words: -2147217885

Keywords: kbbug kbfix kbado260fix kbdatabase kbmdacnosweep kbado250fix KB236624

-

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

© Microsoft Corporation. All rights reserved.