开发者

DataSet.HasChanges is true even immediately after TableAdapter.Update is run

开发者 https://www.devze.com 2022-12-23 05:38 出处:网络
I\'ve got some legacy dataset code which I\'m updating. I\'m attempting to determine if the dataset has changes to it so I can properly prompt for a save request. However myDataset.HasChanges() always

I've got some legacy dataset code which I'm updating. I'm attempting to determine if the dataset has changes to it so I can properly prompt for a save request. However myDataset.HasChanges() always returns true.

In my save method I've edited the code to determine when the dataset get's changes and made the code like this:

1. myBindingSource.EndEdit()
2. myTableAdapter.Update(myDataSet)
3. myBindingSource.EndEdit()

After line 1, - myDataSet.HasChanges = true (understandable)

After line 2, - myDataSet.HasChanges = false (understandable开发者_开发百科)

After line 3, - myDataSet.HasChanges = true

I'm unsure of why this would occur in line 3, shouldn't this be false because I just ran the updates on the dataset?


There may be an UI element causing a value to change within the dataSet/dataTable.

Try your code in a simple consoleApplication without any DataBinding.


Does your TableAdapter refresh your DataSet? If it does, then you probably have something like a key getting initialized (remember, GUID==good, Int==bad). It's just like when you fill from a TableAdapter you need to call AcceptChanges to reset the state of all of the rows to unchanged.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号