9.6 Accepting or Rejecting Changes to Rows

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 both the rows and columns that have been changed.

The DataRow has three methods GetChanges( ) , AcceptChanges( ) , and RejectChanges( ) that can commit or discard the changes made to a DataRow since it was last loaded or since AcceptChanges( ) was last called. These methods function identically to the same methods for the DataSet that 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 and from there are called implicitly on all rows in the table.