Export (0) Print
Expand All

DataTable.GetChanges Method

Gets a copy of the DataTable containing all changes made to it since it was last loaded, or since AcceptChanges was called.

Overload List

Gets a copy of the DataTable that contains all changes made to it since it was loaded or AcceptChanges was last called.

[Visual Basic] Overloads Public Function GetChanges() As DataTable
[C#] public DataTable GetChanges();
[C++] public: DataTable* GetChanges();
[JScript] public function GetChanges() : DataTable;

Gets a copy of the DataTable containing all changes made to it since it was last loaded, or since AcceptChanges was called, filtered by DataRowState.

[Visual Basic] Overloads Public Function GetChanges(DataRowState) As DataTable
[C#] public DataTable GetChanges(DataRowState);
[C++] public: DataTable* GetChanges(DataRowState);
[JScript] public function GetChanges(DataRowState) : DataTable;

Example

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of GetChanges. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Private Sub ProcessDeletes(myDataTable As DataTable, myDataAdapter As OleDbDataAdapter)
   Dim xDataTable As DataTable = myDataTable.GetChanges(DataRowState.Deleted)

   ' Check the DataTable for errors.
   If xDataTable.HasErrors Then
      ' Insert code to resolve errors.
   End If

   ' After fixing errors, update the database with the DataAdapter 
   myDataAdapter.Update(xDataTable)
End Sub

[C#] 
private void ProcessDeletes(DataTable myDataTable, OleDbDataAdapter myDataAdapter)
{
   DataTable xDataTable = myDataTable.GetChanges(DataRowState.Deleted);

   // Check the DataTable for errors.
   if (xDataTable.HasErrors)
   {
      // Insert code to resolve errors.
   }

   // After fixing errors, update the database with the DataAdapter 
   myDataAdapter.Update(xDataTable);
}

[C++] 
private:
    void ProcessDeletes(DataTable* myDataTable, OleDbDataAdapter* myDataAdapter)
    {
    DataTable* xDataTable;
    // Check the DataTable for errors.
    xDataTable = myDataTable->GetChanges(DataRowState::Deleted);

    if (xDataTable->HasErrors)
    {
        // Insert code to resolve errors.
    }

    // After fixing errors, update the database with the DataAdapter
    myDataAdapter->Update(xDataTable);

    };

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

DataTable Class | DataTable Members | System.Data Namespace

Show:
© 2014 Microsoft