This documentation is archived and is not being maintained.

DataTable.GetChanges Method ()

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

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

public DataTable GetChanges ()
public DataTable GetChanges ()
public function GetChanges () : DataTable

Return Value

A copy of the changes from this DataTable, or a null reference (Nothing in Visual Basic) if no changes are found.

Gets a copy of the DataTable that contains all changes made to it since it was loaded or AcceptChanges was last called. This copy is particularly designed so that it can be merged back into the original DataTable. Relationship constraints may cause unchanged parent rows to be included. If no rows are found to be changed, the method returns a null reference (Nothing in Visual Basic).

private void UpdateDataTable(DataTable table, 
    OleDbDataAdapter myDataAdapter)
{
    DataTable xDataTable = table.GetChanges();

    // 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);


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0
Show: