DataRow.GetColumnError 方法

定義

取得資料行的錯誤描述。

多載

GetColumnError(String)

取得名稱指定的資料行的錯誤描述。

GetColumnError(DataColumn)

取得指定 DataColumn 的錯誤描述。

GetColumnError(Int32)

取得索引指定的資料行的錯誤描述。

GetColumnError(String)

來源:
DataRow.cs
來源:
DataRow.cs
來源:
DataRow.cs

取得名稱指定的資料行的錯誤描述。

public:
 System::String ^ GetColumnError(System::String ^ columnName);
public string GetColumnError (string columnName);
member this.GetColumnError : string -> string
Public Function GetColumnError (columnName As String) As String

參數

columnName
String

資料行名稱。

傳回

錯誤描述的文字。

範例

下列範例會設定指定 DataRow之的錯誤描述。

private void SetColError(DataRow row, int columnIndex)
{
    string errorString = "Replace this text.";

    // Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString);
}

private void PrintColError(DataRow row, int columnIndex)
{
    // Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex));
}
Private Sub SetColError(ByVal row As DataRow, _
    byVal columnIndex As Integer)
    Dim errorString As String = "Replace this text."

    ' Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString)
End Sub
 
Private Sub PrintColError( _
    ByVal row As DataRow, byVal columnIndex As Integer)

    ' Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex))
End Sub

備註

SetColumnError使用方法來設定資料行錯誤。

若要判斷數據行集合是否有任何錯誤存在,請使用 HasErrors 方法。 因此,您可以使用 GetColumnsInError 方法來擷取所有發生錯誤的數據行。

若要清除資料行集合的所有錯誤,請使用 ClearErrors 方法。

另請參閱

適用於

GetColumnError(DataColumn)

來源:
DataRow.cs
來源:
DataRow.cs
來源:
DataRow.cs

取得指定 DataColumn 的錯誤描述。

public:
 System::String ^ GetColumnError(System::Data::DataColumn ^ column);
public string GetColumnError (System.Data.DataColumn column);
member this.GetColumnError : System.Data.DataColumn -> string
Public Function GetColumnError (column As DataColumn) As String

參數

傳回

錯誤描述的文字。

範例

下列範例會設定指定 DataRow之的錯誤描述。

private void SetColError(DataRow row, int columnIndex)
{
    string errorString = "Replace this text.";

    // Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString);
}

private void PrintColError(DataRow row, int columnIndex)
{
    // Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex));
}
Private Sub SetColError(ByVal row As DataRow, _
    byVal columnIndex As Integer)
    Dim errorString As String = "Replace this text."

    ' Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString)
End Sub
 
Private Sub PrintColError( _
    ByVal row As DataRow, byVal columnIndex As Integer)

    ' Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex))
End Sub

備註

SetColumnError使用方法來設定資料行錯誤。

若要判斷數據行集合是否有任何錯誤存在,請使用 HasErrors 方法。 因此,您可以使用 GetColumnsInError 方法來擷取所有發生錯誤的數據行。 或者,的 DataTable 方法會GetErrors傳回發生錯誤的所有數據列。

若要清除資料行集合的所有錯誤,請使用 ClearErrors 方法。

另請參閱

適用於

GetColumnError(Int32)

來源:
DataRow.cs
來源:
DataRow.cs
來源:
DataRow.cs

取得索引指定的資料行的錯誤描述。

public:
 System::String ^ GetColumnError(int columnIndex);
public string GetColumnError (int columnIndex);
member this.GetColumnError : int -> string
Public Function GetColumnError (columnIndex As Integer) As String

參數

columnIndex
Int32

資料行的以零起始的索引。

傳回

錯誤描述的文字。

例外狀況

columnIndex 引數超出範圍。

範例

下列範例會設定指定 DataRow之的錯誤描述。

private void SetColError(DataRow row, int columnIndex)
{
    string errorString = "Replace this text.";

    // Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString);
}

private void PrintColError(DataRow row, int columnIndex)
{
    // Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex));
}
Private Sub SetColError(ByVal row As DataRow, _
    byVal columnIndex As Integer)
    Dim errorString As String = "Replace this text."

    ' Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString)
End Sub
 
Private Sub PrintColError( _
    ByVal row As DataRow, byVal columnIndex As Integer)

    ' Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex))
End Sub

備註

SetColumnError使用方法來設定資料行錯誤。

若要判斷數據行集合是否有任何錯誤存在,請使用 HasErrors 方法。 因此,您可以使用 GetColumnsInError 方法來擷取所有發生錯誤的數據行。

若要清除資料行集合的所有錯誤,請使用 ClearErrors 方法。

另請參閱

適用於