DataRow.ClearErrors 메서드

정의

행의 오류를 지웁니다. 여기에는 RowErrorSetColumnError(Int32, String)와 함께 설정된 오류가 포함됩니다.

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

예제

다음 예제에서는 을 HasErrors 사용하여 오류를 찾습니다. 행에 오류가 있는 경우 메서드는 GetColumnsInError 해결할 수 있는 오류가 있는 열 배열을 반환합니다. ClearErrors 그런 다음 모든 오류를 지우기 위해 메서드가 호출됩니다.

private void GetAllErrs(DataRow row)
{
    // Declare an array variable for DataColumn objects.
    DataColumn[] colArr;
    // If the Row has errors, check use GetColumnsInError.
    if(row.HasErrors)
    {
        // Get the array of columns in error.
        colArr = row.GetColumnsInError();
        for(int i = 0; i < colArr.Length; i++)
        {
            // Insert code to fix errors on each column.
            Console.WriteLine(colArr[i].ColumnName);
        }
        // Clear errors after reconciling.
        row.ClearErrors();
    }
}
Private Sub GetAllErrs(ByVal row As DataRow)
    ' Declare an array variable for DataColumn objects.
    Dim colArr() As DataColumn 

    ' If the Row has errors, check use GetColumnsInError.
    Dim i As Integer
    If row.HasErrors Then 
       ' Get the array of columns in error.
       colArr = row.GetColumnsInError()
       For i = 0 to colArr.GetUpperBound(0)
          ' Insert code to fix errors on each column.
          Console.WriteLine(colArr(i).ColumnName)
       Next i

    ' Clear errors after reconciling.
    row.ClearErrors()
    End If
 End Sub

설명

GetColumnError 를 사용하여 SetColumnError 개별 열에 대한 오류를 설정하고 반환합니다.

RowError 속성을 설정하여 전체 행에 적용되는 오류를 설정합니다.

열 컬렉션에 대한 오류가 있는지 여부를 확인하려면 메서드를 HasErrors 사용합니다. 따라서 메서드를 GetColumnsInError 사용하여 오류가 있는 모든 열을 검색할 수 있습니다.

적용 대상

추가 정보