DataSet.AcceptChanges 메서드

정의

DataSet이 로드된 이후 또는 AcceptChanges()가 마지막으로 호출된 이후에 변경된 DataSet의 모든 내용을 커밋합니다.

public:
 void AcceptChanges();
public void AcceptChanges ();
member this.AcceptChanges : unit -> unit
Public Sub AcceptChanges ()

예제

다음 예제에서는 의 에 를 DataTable 추가합니다.DataSetDataRow 그런 다음 메서드는 AcceptChanges 에 대해 호출 DataSet되며, 이 메서드는 포함된 모든 DataTable 개체에 계단식으로 연결됩니다.

private void AcceptChanges()
{
   DataSet myDataSet;
   myDataSet = new DataSet();

   // Not shown: methods to fill the DataSet with data.
   DataTable t;
   t = myDataSet.Tables["Suppliers"];

   // Add a DataRow to a table.
   DataRow myRow;
   myRow = t.NewRow();
   myRow["CompanyID"] = "NWTRADECO";
   myRow["CompanyName"] = "NortWest Trade Company";

   // Add the row.
   t.Rows.Add( myRow );

   // Calling AcceptChanges on the DataSet causes AcceptChanges to be
   // called on all subordinate objects.
   myDataSet.AcceptChanges();
}
Private Sub AcceptChanges()
   Dim myDataSet As DataSet
   myDataSet = new DataSet()

   ' Not shown: methods to fill the DataSet with data.
   Dim t As DataTable

   t = myDataSet.Tables("Suppliers")

   ' Add a DataRow to a table.
   Dim myRow As DataRow
   myRow = t.NewRow()
   myRow("CompanyID") = "NWTRADECO"
   myRow("CompanyName") = "NortWest Trade Company"

   ' Add the row.
   t.Rows.Add( myRow )

   ' Calling AcceptChanges on the DataSet causes AcceptChanges to be
   ' called on all subordinate objects.
   myDataSet.AcceptChanges()
End Sub

설명

DataRowDataTable 클래스에는 모두 메서드가 있습니다AcceptChanges. DataTable 수준에서 를 호출 AcceptChanges 하면 AcceptChangesDataRow 에 대한 메서드가 호출됩니다. 마찬가지로 의 각 테이블에서 호출되는 원인에 대해 를 호출 AcceptChangesDataSet 합니다DataSet.AcceptChanges 이러한 방식으로 메서드를 호출할 수 있는 여러 수준이 있습니다. 의 를 AcceptChangesDataSet 호출하면 한 번의 호출로 모든 하위 개체(예: 테이블 및 행)에서 메서드를 호출할 수 있습니다.

에서 를 DataSet호출 AcceptChanges 하면 편집 모드에 있는 모든 DataRow 개체가 편집을 성공적으로 종료합니다. RowStateDataRow 의 속성도 변경 Added 되고 Modified 행은 가 되고 UnchangedDeleted 행은 제거됩니다.

DataSet 개체가 ForeignKeyConstraint 포함된 경우 메서드를 AcceptChanges 호출하면 도 AcceptRejectRule 적용됩니다.

참고

AcceptChangesRejectChanges 는 관련 변경 내용(즉, 추가, 제거, 삭제 및 수정)에만 적용 DataRow 됩니다. 스키마 또는 구조적 변경에는 적용되지 않습니다.

DataAdapter 사용하여 데이터 세트를 채운 경우 AcceptChanges를 호출해도 이러한 변경 내용이 데이터 원본에 다시 복제되지 않습니다. 이 경우 대신 를 호출합니다 Update . 자세한 내용은 DataAdapters를 사용하여 데이터 원본 업데이트를 참조하세요.

적용 대상

추가 정보