DataSet.HasChanges 메서드

정의

DataSet에 새 행, 삭제된 행 또는 수정된 행을 포함하여 변경 내용이 있는지 여부를 나타내는 값을 가져옵니다.

오버로드

HasChanges()

DataSet에 새 행, 삭제된 행 또는 수정된 행을 포함하여 변경 내용이 있는지 여부를 나타내는 값을 가져옵니다.

HasChanges(DataRowState)

DataSet에 새 행, 삭제된 행 또는 수정된 행을 포함하여 DataRowState를 기준으로 필터링된 변경 내용이 있는지 여부를 나타내는 값을 가져옵니다.

HasChanges()

DataSet에 새 행, 삭제된 행 또는 수정된 행을 포함하여 변경 내용이 있는지 여부를 나타내는 값을 가져옵니다.

public:
 bool HasChanges();
public bool HasChanges ();
member this.HasChanges : unit -> bool
Public Function HasChanges () As Boolean

반환

Boolean

DataSet에 변경 내용이 있으면 true이고, 그렇지 않으면 false입니다.

예제

다음 예제에서는 메서드를 GetChanges 사용하여 데이터 원본을 업데이트하는 데 사용되는 두 번째 DataSet 개체를 만듭니다.

private void UpdateDataSet(DataSet dataSet)
{
    // Check for changes with the HasChanges method first.
    if(!dataSet.HasChanges()) return;

    // Create temporary DataSet variable.
    DataSet tempDataSet;

    // GetChanges for modified rows only.
    tempDataSet = dataSet.GetChanges(DataRowState.Modified);

    // Check the DataSet for errors.
    if(tempDataSet.HasErrors)
    {
        // Insert code to resolve errors.
    }
    // After fixing errors, update the data source with
    // the DataAdapter used to create the DataSet.
    myOleDbDataAdapter.Update(tempDataSet);
}
Private Sub UpdateDataSet(ByVal dataSet As DataSet)
    ' Check for changes with the HasChanges method first.
    If Not dataSet.HasChanges() Then 
        Exit Sub
    End If

    ' Create temporary DataSet variable.
    ' GetChanges for modified rows only.
    Dim tempDataSet As DataSet = _
        dataSet.GetChanges(DataRowState.Modified)

    ' Check the DataSet for errors.
    If tempDataSet.HasErrors Then
       ' Insert code to resolve errors.
    End If

    ' After fixing errors, update the data source with 
    ' the DataAdapter used to create the DataSet.
    myOleDbDataAdapter.Update(tempDataSet)
End Sub

추가 정보

적용 대상

HasChanges(DataRowState)

DataSet에 새 행, 삭제된 행 또는 수정된 행을 포함하여 DataRowState를 기준으로 필터링된 변경 내용이 있는지 여부를 나타내는 값을 가져옵니다.

public:
 bool HasChanges(System::Data::DataRowState rowStates);
public bool HasChanges (System.Data.DataRowState rowStates);
member this.HasChanges : System.Data.DataRowState -> bool
Public Function HasChanges (rowStates As DataRowState) As Boolean

매개 변수

rowStates
DataRowState

DataRowState 값 중 하나입니다.

반환

Boolean

DataSet에 변경 내용이 있으면 true이고, 그렇지 않으면 false입니다.

예제

다음 예제에서는 메서드를 GetChanges 사용하여 두 번째 DataSet 개체를 만든 다음 데이터 원본을 업데이트하는 데 사용됩니다.

private void UpdateDataSet(DataSet dataSet)
{
    // Check for changes with the HasChanges method first.
    if(!dataSet.HasChanges(DataRowState.Modified)) return;

    // Create temporary DataSet variable and
    // GetChanges for modified rows only.
    DataSet tempDataSet =
        dataSet.GetChanges(DataRowState.Modified);

    // Check the DataSet for errors.
    if(tempDataSet.HasErrors)
    {
        // Insert code to resolve errors.
    }
    // After fixing errors, update the data source with
    // the DataAdapter used to create the DataSet.
    adapter.Update(tempDataSet);
}
Private Sub UpdateDataSet(ByVal dataSet As DataSet)
   ' Check for changes with the HasChanges method first.
   If Not dataSet.HasChanges(DataRowState.Modified) Then 
       Exit Sub
   End If

   ' Create temporary DataSet variable and
   ' GetChanges for modified rows only.
   Dim tempDataSet As DataSet = _
       dataSet.GetChanges(DataRowState.Modified)

   ' Check the DataSet for errors.
   If tempDataSet.HasErrors Then
      ' Insert code to resolve errors.
   End If

   ' After fixing errors, update the data source with   
   ' the DataAdapter used to create the DataSet.
   adapter.Update(tempDataSet)
End Sub

설명

메서드를 HasChanges 호출하기 전에 해당 DataSet 속성을 검사합니다 GetChanges .

추가 정보

적용 대상