System.Data.DataSet.AcceptChanges Method

Commits all the changes made to this System.Data.DataSet since it was loaded or since the last time DataSet.AcceptChanges was called.

Syntax

public void AcceptChanges ()

Remarks

Both the System.Data.DataRow and System.Data.DataTable classes have DataSet.AcceptChanges methods. Calling DataTable.AcceptChanges at the System.Data.DataTable level causes the DataRow.AcceptChanges method for each System.Data.DataRow to be called. Similarly, invoking DataSet.AcceptChanges on the System.Data.DataSet causes DataTable.AcceptChanges to be called on each table within the System.Data.DataSet. In this manner, you have multiple levels at which the method can be invoked. Calling the DataSet.AcceptChanges of the System.Data.DataSet enables you to invoke the method on all subordinate objects (for example, tables and rows) with one call.

When you call AcceptChanges on the DataSet, any System.Data.DataRow objects still in edit-mode end their edits successfully. The DataRow.RowState property of each System.Data.DataRow also changes; Added and Modified rows become Unchanged, and Deleted rows are removed.

If the DataSet contains System.Data.ForeignKeyConstraint objects, invoking the AcceptChanges method also causes the ForeignKeyConstraint.AcceptRejectRule to be enforced.

Note:

AcceptChanges and RejectChanges only apply to DataRow related changes (that is, Add, Remove, Delete, and Modify). They are not applicable to schema or structural changes.

Calling AcceptChanges will not replicate these changes back to the data source if the DataSet was filled using a DataAdapter. In that situation, call System.Data.Common.DataAdapter.Update(DataSet) instead. See tp://msdn.microsoft.com/library/33y2221y.aspx for more information.

Requirements

Namespace: System.Data
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0