Click to See Complete Forum and Search --> : Datagrid
darylcollins@op2.co.uk
Apr 12th, 2000, 05:01 PM
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
Forest Dragon
Apr 13th, 2000, 06:30 PM
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!!!
darylcollins@op2.co.uk
Apr 13th, 2000, 10:15 PM
I've checked and it is not the primary key that changes any further help would be appreciated.
Daryl
Forest Dragon
Apr 14th, 2000, 01:56 PM
Try refreshing the DataGrid after every update.
Good Luck!!!
darylcollins@op2.co.uk
Apr 16th, 2000, 03:19 PM
Would you requery after columns update, your help would be appreciated.
daryl
pardede
Apr 16th, 2000, 09:19 PM
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):
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
darylcollins@op2.co.uk
Apr 16th, 2000, 09:28 PM
How would I loop through all of my bound controls your help would be appreciated!!
pardede
Apr 17th, 2000, 04:08 AM
Code will look like this:
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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.