DataTable.AcceptChanges メソッド
アセンブリ: System.Data (system.data.dll 内)


AcceptChanges が呼び出されると、編集モードの DataRow オブジェクトは、正常に編集を終了します。また、DataRowState も変更されます。すべての Added 行および Modified 行は、Unchanged に変更されます。Deleted 行は削除されます。
通常、DbDataAdapter.Update メソッドを使用して DataSet を更新しようとした後に、AcceptChanges メソッドが DataTable で呼び出されます。

各テーブルにエラーがあるかどうかを確認する例を次に示します。テーブルのエラーを (未定義関数にエラーを渡して) 調整できる場合は AcceptChanges が呼び出されます。それ以外の場合は RejectChanges が呼び出されます。
Private Sub AcceptOrReject(table As DataTable) ' If there are errors, try to reconcile. If( Not table.HasErrors) If(Reconcile(table)) ' Fixed all errors. table.AcceptChanges Else ' Couldn'table fix all errors. table.RejectChanges End If Else ' If no errors, AcceptChanges. table.AcceptChanges() End If End Sub Private Function Reconcile(thisTable As DataTable) As Boolean Dim row As DataRow For Each row in thisTable.Rows 'Insert code to try to reconcile error. ' If there are still errors return immediately ' since the caller rejects all changes upon error. If row.HasErrors Then Reconcile = False Exit Function End If Next row Reconcile = True End Function
private void AcceptOrReject(DataTable table) { // If there are errors, try to reconcile. if(!table.HasErrors) { if(Reconcile(table)) { // Fixed all errors. table.AcceptChanges(); } else { // Couldn'table fix all errors. table.RejectChanges(); } } else // If no errors, AcceptChanges. table.AcceptChanges(); } private bool Reconcile(DataTable thisTable) { foreach(DataRow row in thisTable.Rows) { //Insert code to try to reconcile error. // If there are still errors return immediately // since the caller rejects all changes upon error. if(row.HasErrors) return false; } return true; }

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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDataTable.AcceptChanges メソッドを検索する場合は、下記のリンクをクリックしてください。

- DataTable.AcceptChanges メソッドのページへのリンク