GetChanges
DataSetds
= DataSet.GetChanges(); DataSetds
= DataSet.GetChanges(DataRowStatedrs
);
Returns a DataSet
with the same schema as the
original DataSet
but which contains only the rows
that have been modified since the last time the
DataSet
was loaded or since
AcceptChanges( )
was last called. This overloaded
method allows the changes to be filtered by the
RowState
of the DataRow
objects.
ds
Returns the DataSet
with all changes made to the
original since it was last loaded or AcceptChanges( )
was last called.
drs
A DataRowState
enumeration value as described in
Table 22-13 specifying the row state of the
DataRow
objects to return.
The following example shows how to create a
DataSet
containing all changed rows and a
DataSet
containing all deleted rows from the
original DataSet
:
// return a DataSet containing all changed rows DataSet dsChanges = dsOriginal.GetChanges(); // return a DataSet containing all deleted rows DataSet dsDeleted = dsOriginal.GetChanges(DataRowState.Deleted);
Parent rows marked unchanged may be included in the rows returned if they are required because of relationship constraints.
The GetChanges( )
method can isolate the rows that
have been changed so that the entire DataSet
doesn’t have to be passed to a method that
reconciles DataSet
changes with the data source.
A null
reference is returned if there are no rows
matching the specified criteria.