DataTable.GetChanges メソッド

定義

最後に読み込まれた後、またはAcceptChanges()が呼び出されてから行われたすべての変更を含むDataTableのコピーを取得します。

オーバーロード

名前 説明
GetChanges()

読み込まれたか、最後に呼び出された後に行われたすべての変更を含むDataTableAcceptChanges()のコピーを取得します。

GetChanges(DataRowState)

最後に読み込まれた後、またはAcceptChanges()が呼び出されてから行われたすべての変更を含むDataTableのコピーをDataRowStateでフィルター処理して取得します。

GetChanges()

読み込まれたか、最後に呼び出された後に行われたすべての変更を含むDataTableAcceptChanges()のコピーを取得します。

public:
 System::Data::DataTable ^ GetChanges();
public System.Data.DataTable GetChanges();
member this.GetChanges : unit -> System.Data.DataTable
Public Function GetChanges () As DataTable

返品

この DataTableからの変更のコピー。変更が見つからない場合は null

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);
}
Private Sub UpdateDataTable(table As DataTable, _
    myDataAdapter As OleDbDataAdapter)

    Dim xDataTable As DataTable = table.GetChanges()

    ' 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

注釈

保留中の変更がある元のDataSet内のすべての行のコピーを含む新しいDataSetを作成します。 変更されていない行に変更された行の外部キーに対応する主キーが含まれている場合、リレーションシップの制約により、変更されていない行が新しい DataSet に追加される可能性があります。 保留中の変更<元のに行がない場合、このメソッドは (Visual Basic では ) を返します。

こちらもご覧ください

適用対象

GetChanges(DataRowState)

最後に読み込まれた後、またはAcceptChanges()が呼び出されてから行われたすべての変更を含むDataTableのコピーをDataRowStateでフィルター処理して取得します。

public:
 System::Data::DataTable ^ GetChanges(System::Data::DataRowState rowStates);
public System.Data.DataTable GetChanges(System.Data.DataRowState rowStates);
member this.GetChanges : System.Data.DataRowState -> System.Data.DataTable
Public Function GetChanges (rowStates As DataRowState) As DataTable

パラメーター

rowStates
DataRowState

DataRowState値の 1 つ。

返品

DataTableに対してアクションを実行でき、後でMerge(DataSet)を使用してDataTableにマージされるフィルター処理されたコピー。 目的の DataRowState の行が見つからない場合、メソッドは nullを返します。

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);
}
Private Sub ProcessDeletes(table As DataTable, _
    adapter As OleDbDataAdapter)

   Dim changeTable As DataTable = table.GetChanges(DataRowState.Deleted)

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

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

注釈

GetChanges メソッドは、元のオブジェクトに導入された変更のみを含む 2 つ目のDataTable オブジェクトを生成するために使用されます。 rowStates引数を使用して、新しいオブジェクトに含める変更の種類を指定します。

リレーションシップの制約により、変更されていない親行が含まれる可能性があります。

こちらもご覧ください

適用対象