NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DataSet.AcceptChanges

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

[Visual Basic]
Public Sub AcceptChanges()
[C#]
public void AcceptChanges();
[C++]
public: void AcceptChanges();
[JScript]
public function AcceptChanges();

Remarks

Both the DataRow and DataTable classes also have AcceptChanges methods. Invoking AcceptChanges on the DataSet causes AcceptChanges to be called on each table in a DataSet. Consequently, calling AcceptChanges on each DataTable causes each DataRow object's AcceptChanges method to be called. In this manner, you have multiple levels at which the method can be invoked. Calling the DataSet class's AcceptChanges, however, allows you to invoke the method all subordinate objects (tables and rows) with one call.

The AcceptChanges method is called after you have called the BeginEdit method of a DataRow object (or objects). Thus you can have several rows in edit state where changes are arbitarily made, and no constraints are applied.

Any DataRow objects still in edit-mode successfully end their edits. The RowState property of each DataRow also changes; New and Modified rows become Unchanged, and Deleted rows are removed.

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

Example [Visual Basic]

[Visual Basic]

Private Sub AcceptChanges()
   Dim myDataSet As DataSet
   ' The SuppliersProducts class derives from DataSet.
   myDataSet = New SuppliersProducts
   ' Not shown: methods to fill the DataSet with data.
   Dim t As DataTable
   t = myDataSet.Tables("Suppliers")
   ' Add a DataRow to a table.
   Dim myRow As DataRow
   myRow = t.NewRow
   myRow("CompanyID") = "NWTRADECO"
   myRow("CompanyName") = "NortWest Trade Company"
   ' Begin edit and add the row.
   t.BeginEdit
   t.Rows.Add(myRow)
   ' Calling AcceptChanges on the DataSet causes AcceptChanges to be
   ' called on all subordinate objects.
   t.EndEdit
   myDataSet.AcceptChanges
End Sub

See Also

DataSet Class | DataSet Members | System.Data Namespace | AcceptChanges | AcceptRejectRule | BeginEdit | DataRow | ForeignKeyConstraint