DataSet.HasErrors 속성

정의

DataTable 내의 DataSet 개체에 오류가 있는지 여부를 나타내는 값을 가져옵니다.

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

속성 값

Boolean

true테이블에 오류가 있으면 이고, 그렇지 않으면 . false

특성

예제

다음 예제에서는 속성을 사용 하 여 HasErrors 개체에 오류가 포함 되어 있는지 여부를 DataSet 확인 합니다. 이 경우 각 DataRow DataTable 항목에 대한 오류가 인쇄됩니다.

private void CheckForErrors()
{
    if(!DataSet1.HasErrors)
    {
        DataSet1.Merge(DataSet2);
    }
    else
    {
        PrintRowErrs(DataSet1);
    }
}

private void PrintRowErrs(DataSet dataSet)
{
    foreach(DataTable table in dataSet.Tables)
    {
        foreach(DataRow row in table.Rows)
        {
            if(row.HasErrors)
            {
                Console.WriteLine(row.RowError);
            }
        }
    }
}
Private Sub CheckForErrors()
    If Not DataSet1.HasErrors Then
        DataSet1.Merge(DataSet2)
    Else
       PrintRowErrs(DataSet1)
    End If
End Sub
 
Private Sub PrintRowErrs(ByVal dataSet As DataSet)
    Dim row As DataRow
    Dim table As DataTable
    For Each table In  dataSet.Tables
       For Each row In table.Rows
          If row.HasErrors Then
             Console.WriteLine(row.RowError)
          End If
       Next
    Next
End Sub

설명

DataTable 항목 DataSet 에는 속성도 있습니다 HasErrors . 개별 DataTable 개체를 HasErrors 확인하기 전에 첫 번째 DataSet 속성을 사용하여 테이블에 오류가 있는지 확인합니다. 오류가 있는 DataTable 경우 메서드는 GetErrors 오류를 포함하는 개체 배열 DataRow 을 반환합니다.

적용 대상

추가 정보