다음을 통해 공유


DataSet.AcceptChanges 메서드

정의

로드되었거나 마지막으로 AcceptChanges() 호출된 이후의 DataSet 변경 내용을 모두 커밋합니다.

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

예제

다음 예제에서는 에 a DataRowDataTable 를 추가합니다 DataSet. AcceptChanges 그런 다음, 메서드가 포함된 모든 DataTable 개체로 계단식으로 이동되는 메서드를 호출DataSet합니다.

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

설명

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

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

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

메모

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

DataSet이 DataAdapter를 사용하여 채워진 경우 AcceptChanges를 호출하면 이러한 변경 내용이 데이터 원본으로 다시 복제되지 않습니다. 이 경우 대신 전화하십시오 Update . 자세한 내용은 DataAdapters를 사용하여 데이터 원본 업데이트를 참조하세요.

적용 대상

추가 정보