Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GetChanges Method (DataRowState)
Collapse the table of content
Expand the table of content

DataTable.GetChanges Method (DataRowState)

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.

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

public DataTable GetChanges (
	DataRowState rowStates
)
public DataTable GetChanges (
	DataRowState rowStates
)
public function GetChanges (
	rowStates : DataRowState
) : DataTable

Parameters

rowStates

One of the DataRowState values.

Return Value

A filtered copy of the DataTable that can have actions performed on it, and subsequently be merged back in using Merge. If no rows of the desired DataRowState are found, the method returns a null reference (Nothing in Visual Basic).

The GetChanges method is used to produce a second DataTable object which contains only the changes introduced into the original. Use the rowStates argument to specify the type of changes the new object should include.

Relationship constraints may cause unchanged parent rows to be included.

private void ProcessDeletes(DataTable table, 
    OleDbDataAdapter adapter)
{
    DataTable changeTable = table.GetChanges(DataRowState.Deleted);

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

    // After fixing errors, update the database with the DataAdapter 
    adapter.Update(changeTable);


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

Community Additions

ADD
Show:
© 2015 Microsoft