0

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()
4

2 回答 2

1

我忘了打电话 .endcurrentEdit()

BindingContext(DsEditObject1, "Object").EndCurrentEdit()
于 2013-06-27T09:53:40.420 回答
0

可悲的是,您的 BindingContext 阻止了更改。通常 SqlDataAdapter.Update 会立即将更新发送到数据库,但看起来您的 BindingContext 为您保存了所有更新,因此您可以在需要时取消它。

我会将您的 DataSet 从 Context 中取出,以便它立即更新。

于 2013-06-27T17:36:25.800 回答