[RESOLVED] "Row cannot be located for updating" - when updating db recursively
In the following code I'm recursively saving current vieworder of a Treeview's nodes to a Access2000 db. I'm using ADO 2.8. (The original code was for saving treeview vieworder in a text file. I found it somewhere on the web)
At first I was getting an error, -2147217864 : Row cannot be located for updating. Some values may have been changed since it was last read.
I tried using .Requery, Close-Reopen, .Update, but nothing worked. Then finally the .Resync method worked. I'm not sure why it worked !
My problem is, this Requery process is painfully slow. Every time user adds a node and the treeview has, say, >10 nodes, it is taking 10-20 seconds ! Every time user adds/deletes/sorts/drags node, I have to update their viewing index in db.
I don't have very much experience in database programming. (My instinct says it may have something to do with recursion and stack.)
1. Can anyone please tell me why that Resync method works and why everything else fails even if I perform a CommitTrans ?
2. Can anyone plese help me make this code faster.
Thanks !
VB Code:
Friend Sub ParseTree(objNode As Node)
' Recursively updates TreeIndex field in DB according to the node's level
Re: "Row cannot be located for updating" - when updating db recursively
Well there's two possible issues I can think of, the first is that .Find is doing something to cause it (you could try updating the first record without it to see if that works).
The second thing I can think of is that you do not have a unique identifier for the row, so when you update a row which is similar to another, this error is shown to stop a possible update to the wrong row.
Re: "Row cannot be located for updating" - when updating db recursively
Originally Posted by si_the_geek
Well there's two possible issues I can think of, the first is that .Find is doing something to cause it (you could try updating the first record without it to see if that works).
Thanks. I'll try it.
Originally Posted by si_the_geek
The second thing I can think of is that you do not have a unique identifier for the row, so when you update a row which is similar to another, this error is shown to stop a possible update to the wrong row.
Sorry I don't understand it. I have primary keys in the db (autonumber).
Here is my query:
VB Code:
With rs
.ActiveConnection = cnn
.LockType = adLockOptimistic
.Open "SELECT * FROM tblNotes ORDER BY IsNote DESC,[TreeIndex]"