views:

173

answers:

1

I'm confused as to the effect of using AcceptChanges within a dataset. It appears from my tests that this forces the database changes to be comitted, disregarding any constraints on the database.

Can anyone confirm if this is the case, or if not, how this differs from using the Update function on the dataset?

+4  A: 

AcceptChanges doesn't affect your database, it only affects the DataSet (your in-memory copy of the data).

Using AcceptChanges will cause all Datarows of all tables in the data set to have its Rowstate reset to RowState.Unchanged.

You would normally use AcceptChanges together with the DataTable.GetChanges method. Or with the DbDataAdapter.Update method. You would use either of them to get the changes or to persist the changes to the database, and you would then use AcceptChanges to tell the DataSet that the changes have been stored.

Rune Grimstad
DataAdapter.Update will call AcceptChanges row-by-row on your behalf, so there is no need to call it yourself after calling Update
McKenzieG1
Hmm. You are right. Good point!
Rune Grimstad