Click to See Complete Forum and Search --> : The heck with Concurrency 0 Rows Affected
JSawyer
July 26th, 2005, 11:31 AM
I'm sure everyone's had or knows of this error, however I have a question on it. I utilize an access database for only 1 person. So when I go to update the database, I don't care if the original values don't match up, I want everything in that database overwritten. The first save works swell, its the blasted second, third, etc. that don't work. I've worked around this by refilling the dataset after each database update. Is there another way to going about this? I believe it's a waste of time to constantly refilling the dataset.
myahmac
July 26th, 2005, 03:13 PM
I don't believe you have to fill your dataset everytime. When I started my app I just filled once on form load. Then Everytime I made chanegs, whether I created a new record, edited one, etc.
This is my code for saving....
Try
'close editing so that changes can be transmitted.
BindingContext(dataSet, "Table").EndCurrentEdit()
'tell the adpater to update the current dataset
dataAdapter.Update(dataSet, "Table")
'tell the dataset TO accept the changes in the DataBAse.
dsEditor.AcceptChanges()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
From what I understand you interface should make changes to the dataset which is in memory. When you call an update it updates the database to reflect what is in memory. Thus you do not need to refill from database to memory, if that helps.
JSawyer
July 26th, 2005, 05:54 PM
Well, i wasn't using BindingContext. I put that in and it seems to work now. Not sure why though. Note that you don't have to call AcceptChanges because the adapter.update automatically takes care of that. I do have a problem with Opening a database now. Whenever I add a new record, my autoincrement ID field restarts at 1 when I use table.newrow. Any suggestions?
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.