7.7 Committing and Discarding Changes
When a DataRow is
modified, ADO.NET marks the row as having a pending change and sets
the RowState of the DataRow to
Added, Modified, or
Deleted as appropriate. ADO.NET also maintains
version information by tracking both Original and
Current versions of each row. Together, this
information allows ADO.NET to identify the rows and columns that have
been changed.
The DataTable has three
methods—GetChanges(
)
, AcceptChanges(
), and RejectChanges( )—that can
commit or discard the changes made to a DataTable
since it was last loaded or since AcceptChanges( )
was last called. These methods function identically to the same
methods for the DataSet as they are described in
Chapter 6. Also, when these methods are called on
a DataSet, they are implicitly called on all
tables contained within the DataSet.
|