BUG: Navigating Through an ADO Recordset Clone May Generate Error -2147217885
ID: Q236624
|
The information in this article applies to:
-
ActiveX Data Objects (ADO), versions 2.0, 2.01, 2.1, 2.1 SP1, 2.1 SP2
SYMPTOMS
Performing the following steps on a disconnected ADO recordset:
- Sort the recordset.
- Delete a record from the recordset.
- Clone the recordset.
- 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:
- Delete a record from the recordset.
- Clone the recordset.
- Filter the recordset Clone.
- Navigate through the recordset Clone using the MoveNext method.
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
MORE INFORMATIONSteps 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:
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=sa;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
- Run the project. You may get error -2147217885.
- Comment out either of the following lines of code:
.Sort = "pub_id"
-or-
rsClone.Filter = "pub_id <= 1000"
- Run the project. You should now be able to run without receiving error -2147217885.
Additional query words:
Keywords : kbADO200bug kbADO201bug kbADO210bug kbDatabase kbSQLServ kbGrpVBDB kbGrp MDAC kbDSupport
Version : WINDOWS:2.0,2.01,2.1,2.1 SP1,2.1 SP2
Platform : WINDOWS
Issue type : kbbug
|