次の方法で共有


DataTable.GetChanges メソッド ()

前回 DataTable を読み込むか、 AcceptChanges を呼び出した以降にこのテーブルに対して行われたすべての変更が格納されているこのテーブルのコピーを取得します。

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

戻り値

この DataTable からの変更のコピー。変更がない場合は null 参照 (Visual Basic では Nothing) 。

解説

前回 DataTable を読み込むか、 AcceptChanges を呼び出した以降にこのテーブルに対して行われたすべての変更が格納されているこのテーブルのコピーを取得します。このコピーは、元の DataTable にマージできるように考慮して設計されています。リレーションシップ制約があるために、Unchanged の親行が含まれる場合があります。これらの rowStates の行が見つからない場合、このメソッドは null 参照 (Visual Basic では Nothing) を返します。

使用例

 
Private Sub UpdateDataTable(myDataTable As DataTable, myDataAdapter As OleDbDataAdapter)
   Dim xDataTable As DataTable = myDataTable.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

[C#] 
private void UpdateDataTable(DataTable myDataTable, OleDbDataAdapter myDataAdapter)
{
   DataTable xDataTable = myDataTable.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);
}

[C++] 
private:
    void UpdateDataTable(DataTable* myDataTable, OleDbDataAdapter* myDataAdapter)
    {
    DataTable* xDataTable = myDataTable->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);
    };

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

DataTable クラス | DataTable メンバ | System.Data 名前空間 | DataTable.GetChanges オーバーロードの一覧