asp.net.ph

DataSet.AcceptChanges Method

System.Data Namespace   DataSet Class


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

[ VB ]
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 AcceptChanges of the DataSet however, allows you to invoke the method on all subordinate objects ( for example, 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; Added 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

The following example adds a DataRow to a DataTable in a DataSet. The AcceptChanges method is then called on the DataSet, which cascades to all DataTable objects it contains.

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"
   ' add the row.
   t.Rows.Add ( myRow )
   ' calling AcceptChanges on the DataSet causes AcceptChanges to
   ' be called on all subordinate objects.
   myDataSet.AcceptChanges
End Sub
See Also

DataSet Members   AcceptChanges   AcceptRejectRule   BeginEdit   DataRow   ForeignKeyConstraint Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph