|
-
Jan 9th, 2006, 06:23 AM
#1
[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
'----------------------------------------
' Update DB
rs.MoveFirst
cnn.BeginTrans
' The Treeview Keys are "_N21" or similar
rs.Find "ID = " & Right$(objNode.Key, Len(objNode.Key) - 2)
rs!TreeIndex = ViewIndex 'ViewIndex is a global var to track current node
' placement in the treeview
'[b]ToDo: This Resync process takes too much time.
' If I comment this:
'[color=red] ERROR -2147217864 : Row cannot be located for updating. _[/color]
'[color=red] Some values may have been changed since it was last read.[/color]
rs.Resync [/b]
cnn.CommitTrans
'----------------------------------------
ViewIndex = ViewIndex + 1
' Check to see if the current node has children
If objNode.Children > 0 Then
' Pass the first child node to the print routine
ParseTree objNode.Child
End If
' Set the next node to print
Set objNode = objNode.Next
' As long as we have not reached the last node in
' a branch, continue to call the print routine
If TypeName(objNode) <> "Nothing" Then
ParseTree objNode
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|