System.Data Namespace DataSet Class
Rolls back all the changes made to the DataSet since it was created, or since the last time DataSet.AcceptChanges was called.
[ VB ]
Overridable Public Sub RejectChanges ( )
[ C# ]
public virtual void RejectChanges ( );
[ C++ ]
public: virtual void RejectChanges ( );
[ JScript ]
public function RejectChanges ( );
Invoke the DataSet.RejectChanges to call the DataTable.RejectChanges method on all DataTable objects contained by the DataSet. Additionally, any Constraint rules contained by the DataSet are enforced.
DataRow objects contained by the DataSet can each be set into edit mode by invoking the DataRow.BeginEdit method. After invoking the DataRow.EndEdit method, changes can be rejected by calling the DataTable.RejectChanges on the DataTable to which the DataRow objects belong.
When the DataTable.RejectChanges method is called, any rows still in edit-mode cancel their edits. New rows are removed. Modified and deleted rows return back to their original state ( DataRowState.Unchanged ).
The following example shows a class derived from the DataSet class. The RejectChanges event invoked from within a function.
private void RejectChangesInDataSet ( ) {
// instantiate the derived DataSet.
DerivedDataSet myDerivedDataSet = new DerivedDataSet ( );
// ... insert code here to change values ...
// invoke the RejectChanges method in the derived class.
myDerivedDataSet.RejectDataSetChanges ( );
}
public class DerivedDataSet:System.Data.DataSet {
void RejectDataSetChanges ( ) {
// invoke the RejectChanges method.
this.RejectChanges ( );
}
}
Private Sub RejectChangesInDataSet ( )
' instantiate the derived DataSet.
Dim myDerivedDataSet As New DerivedDataSet ( )
' ... insert code here to change values ...
' invoke the RejectChanges method in the derived class.
myDerivedDataSet.RejectDataSetChanges ( )
End Sub
Public Class DerivedDataSet
Inherits System.Data.DataSet
Public Sub RejectDataSetChanges ( )
' invoke the RejectChangesmethod.
Me.RejectChanges ( )
End Sub
End Class |
|
C# |
VB |
DataSet Members AcceptChanges