This documentation is archived and is not being maintained.

Committing Changes in a Dataset

As you make changes to records in a dataset by updating, inserting, and deleting records, the dataset maintains original and current versions of the records. In addition, each row's RowState property is set to indicate whether the records are in their original state or if they have been updated, inserted, or deleted. This information is useful when you need to find a particular version of a row. Typically, you would get a subset of all changed records to send to another process. For more information, see Retrieving Changed Rows. After you have processed all the changed rows, you can commit the changes by calling the AcceptChanges method of the dataset.

To commit changes in a dataset

  • Call the dataset's AcceptChanges method.

    The following example shows how to call the AcceptChanges method to commit changes in the Customers table after updating a data source:

    ' Visual Basic
    OleDbDataAdapter1.Update(Dataset1, "Customers")
    // C#
    OleDbDataAdapter1.Update(Dataset1, "Customers");

Copying Information from Another Dataset Before Committing Changes

To copy information from another dataset and then commit the changes

  1. Call the dataset's Merge method.
  2. Call the dataset's AcceptChanges method.

    The following example shows how to commit changes in a dataset after using the Merge method to copy information from a second dataset:

    ' Visual Basic
    // C#

See Also

Dataset Updates in Visual Studio .NET | Retrieving Changed Rows | DataSet.AcceptChanges Method | Data Update Events