Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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")
    Dataset1.Customers.AcceptChanges()
    
    // C#
    OleDbDataAdapter1.Update(Dataset1, "Customers");
    Dataset1.Customers.AcceptChanges();
    

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
    Dataset1.Merge(Dataset2)
    Dataset1.AcceptChanges()
    
    // C#
    Dataset1.Merge(Dataset2);
    Dataset1.AcceptChanges();
    

See Also

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft