|
-
Apr 12th, 2000, 05:01 PM
#1
Thread Starter
Junior Member
Can anyone help me please, I'm using the Datagrid control, using ADO code, if I edit a record and then update it updates fine, but then I edit the same record and try updating but it gives me the following error:-
The specified row could not be located for udpating. Some value may have been changed since it was last read.
Thank you in advance
Daryl
-
Apr 13th, 2000, 06:30 PM
#2
Addicted Member
I think you change the value of the primary key field every time you edit a record and then it cannot be found anymore. Check what the primary key field in your table is, and avoid changing it while editing a record.
Good Luck!!!
-
Apr 13th, 2000, 10:15 PM
#3
Thread Starter
Junior Member
I've checked and it is not the primary key that changes any further help would be appreciated.
Daryl
-
Apr 14th, 2000, 01:56 PM
#4
Addicted Member
Try refreshing the DataGrid after every update.
Good Luck!!!
-
Apr 16th, 2000, 03:19 PM
#5
Thread Starter
Junior Member
Would you requery after columns update, your help would be appreciated.
daryl
-
Apr 16th, 2000, 09:19 PM
#6
Addicted Member
OK, here's what you need to do. After updating, you need to refresh the recordset using Resync method, and then you need to rebind your bound controls to pickup the changes to the recordset. And by the way: do not use Update to save your record, use Move(0) instead because there's a bug in the Update method of ADO. So the code is (assuming rsMyRecordset is the recordset and DataGrid1 as the bound control you use):
Code:
MyRecordset.Move (0) 'save to database
MyRecordset.Resync 'requery
'rebind your bound control
Set DataGrid1.DataSource = DataGrid1.DataSource
If you have more bound controls you can use a loop through all the bound controls to rebind them.
Hope this helps
-
Apr 16th, 2000, 09:28 PM
#7
Thread Starter
Junior Member
How would I loop through all of my bound controls your help would be appreciated!!
-
Apr 17th, 2000, 04:08 AM
#8
Addicted Member
Code will look like this:
Code:
Dim ctl as Control
For Each ctl in frmMyForm.Controls
If TypeOf ctl Is TextBox _
Or TypeOf ctl Is Combobox Then
'you can expand this with more or's...
Set ctl.DataSource = ctl.DataSource
End If
Next
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
|