Reputation: 1501
I'm sure this is trivial. But i can't work out why my database isn't getting updated when i've got similar setups elsewhere which seem to be working correctly.
I have a typed dataset called DSEditObject and an instance of that on my form called DsEditObject1. This dataset has a table in it called 'Object'.
I have a textbox whose databinding text property is: ObjectBindingSource - objectName
This 'ObjectBindingSource' has a datasource property of: DsEditObject1 and a datamember property of 'Object'.
When i load the form i fill the dataset using a dataadapter configured at runtime. The textbox.text property gets set to the column data from my database that i expect.
I handled the click from a save button and call
SqlDataAdapter1.Update(DsEditObject1, "Object")
I have used the command window and checked that the value in the dataset has been changed to the textbox input before the update command gets called:
UPDATE [Object] SET [objectName] = @objectName WHERE (([objectID] = @Original_objectID))
But for some reason my database isn't getting updated and I am receiving no errors
Edit:
i'd forgotten to call .endcurrentEdit()
BindingContext(DsEditObject1, "Object").EndCurrentEdit()
Upvotes: 0
Views: 870
Reputation: 6352
Sadly your BindingContext is holding up the changes. Normally SqlDataAdapter.Update will send the updates to the database immediately, but it looks like your BindingContext is holding all of it for you so that you can cancel it if you need to.
I would get your DataSet out of the Context so that it will update immediately.
Upvotes: 0
Reputation: 1501
i'd forgotten to call .endcurrentEdit()
BindingContext(DsEditObject1, "Object").EndCurrentEdit()
Upvotes: 1