Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of AcceptChanges with SQL Server

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?

like image 283
Paul Michaels Avatar asked Feb 28 '23 08:02

Paul Michaels


1 Answers

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.

like image 85
Rune Grimstad Avatar answered Mar 12 '23 02:03

Rune Grimstad