DataTable.HasErrors 속성

정의

해당 테이블이 속하는 DataSet의 테이블에 있는 행에 오류가 있는지 여부를 나타내는 값을 가져옵니다.

public:
 property bool HasErrors { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool HasErrors { get; }
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataTableHasErrorsDescr")]
public bool HasErrors { get; }
[<System.ComponentModel.Browsable(false)>]
member this.HasErrors : bool
[<System.ComponentModel.Browsable(false)>]
[<System.Data.DataSysDescription("DataTableHasErrorsDescr")>]
member this.HasErrors : bool
Public ReadOnly Property HasErrors As Boolean

속성 값

오류가 있으면 true이고, 그렇지 않으면 false입니다.

특성

예제

다음 예제에서는 속성을 사용하여 HasErrors 테이블에 오류가 있는 경우 검사.

private void CheckForErrors(DataSet dataSet)
{
    // Invoke GetChanges on the DataSet to create a reduced set.
    DataSet thisDataSet = dataSet.GetChanges();

    // Check each table's HasErrors property.
    foreach(DataTable table in thisDataSet.Tables)
    {
        // If HasErrors is true, reconcile errors.
        if(table.HasErrors)
        {
            // Insert code to reconcile errors.
        }
    }
}
Private Sub CheckForErrors(dataSet As DataSet)
    ' Invoke GetChanges on the DataSet to create a reduced set.
    Dim thisDataSet As DataSet = dataSet.GetChanges()

    ' Check each table's HasErrors property.
    Dim table As DataTable
    For Each table In thisDataSet.Tables
        ' If HasErrors is true, reconcile errors.
        If table.HasErrors Then
            ' Insert code to reconcile errors.
        End If
    Next table
End Sub

설명

사용자가 에 포함된 데이터 집합에서 DataTable작업할 때 변경으로 인해 일부 유효성 검사 오류가 발생하는 경우 각 변경 내용에 오류를 표시할 수 있습니다. 속성을 사용하여 전체 DataRow 를 오류 메시지로 표시할 RowError 수 있습니다. 메서드를 사용하여 행 SetColumnError 의 각 열에 오류를 설정할 수도 있습니다.

를 사용하여 데이터 원본을 DataSet업데이트하기 전에 먼저 대상 DataSet에서 메서드를 GetChanges 호출하는 것이 좋습니다. 메서드는 원래 변경 내용만 포함하는 을 생성 DataSet 합니다. 업데이트를 위해 를 데이터 원본으로 보내기 DataSet 전에 각 테이블의 속성을 검사 HasErrors 오류가 행의 행이나 열에 연결되어 있는지 확인합니다.

각 오류를 조정한 후 의 메서드를 사용하여 ClearErrors 오류를 지웁합니다 DataRow.

적용 대상

추가 정보