dwmtractor
IS-IT--Management
Trying to do an efficient delete of multiple records in an ADO recordset bound to a DataGrid control, and populated from an MS Access 2000 database. A row is deleted using the following code:
With dbMain
.Recordset.MoveFirst
Do While .Recordset.EOF <> True
.Recordset.Delete
.Recordset.MoveNext
.Refresh
Loop
End With
At the point of "MoveNext," VB crashes with the error:
"Run-time error '-2147217864 (80040e38):
Row cannot be located for updating. Some values may have been changed since it was last read."
This is a lot like the behavior described in MS bulletin Q300586, except that it doesn't seem to matter whether there's a default value in a numeric index field or not.
The only workaround I've found so far is to use the following:
With dbMain
.Recordset.MoveFirst
Do While .Recordset.EOF <> True
.Recordset.Delete
.Recordset.Update
.Recordset.Requery
Loop
End With
Problem is, this requires a write and then reopen of the table every time and is horribly slow for a large number of records.
Anybody got a clue what's wrong here, or have another suggestion of how I could select multiple records based upon a list of doc numbers, then delete all records with the appropriate doc number?
Thanks
Dan
With dbMain
.Recordset.MoveFirst
Do While .Recordset.EOF <> True
.Recordset.Delete
.Recordset.MoveNext
.Refresh
Loop
End With
At the point of "MoveNext," VB crashes with the error:
"Run-time error '-2147217864 (80040e38):
Row cannot be located for updating. Some values may have been changed since it was last read."
This is a lot like the behavior described in MS bulletin Q300586, except that it doesn't seem to matter whether there's a default value in a numeric index field or not.
The only workaround I've found so far is to use the following:
With dbMain
.Recordset.MoveFirst
Do While .Recordset.EOF <> True
.Recordset.Delete
.Recordset.Update
.Recordset.Requery
Loop
End With
Problem is, this requires a write and then reopen of the table every time and is horribly slow for a large number of records.
Anybody got a clue what's wrong here, or have another suggestion of how I could select multiple records based upon a list of doc numbers, then delete all records with the appropriate doc number?
Thanks
Dan