Handling Changes

Today's final brief discussion deals with notifying the DataTable as to when rows should be “committed” to the table. In other words, at some point you need to know that changed, deleted, and inserted rows can simply be treated as regular rows, most likely because they are now synchronized to the data store.

Using AcceptChanges

The DataSet, DataTable, and DataRow classes all expose AcceptChanges methods that perform the same function although, of course, only in the scopes appropriate for the object. As hinted at previously, when AcceptChanges is called on any of the objects, it performs the following tasks in order:

It calls the EndEdit method for any rows where changes are pending, causing Proposed values to be copied ...

Get Sams Teach Yourself ADO.NET in 21 Days now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.