DataRow.GetColumnError Method

Definition

获取列的错误说明。Gets the error description for a column.

Overloads

GetColumnError(String)

获取由名称指定的列的错误说明。Gets the error description for a column, specified by name.

GetColumnError(DataColumn)

获取指定 DataColumn 的错误说明。Gets the error description of the specified DataColumn.

GetColumnError(Int32)

获取由索引指定的列的错误说明。Gets the error description for the column specified by index.

GetColumnError(String)

获取由名称指定的列的错误说明。Gets the error description for a column, specified by name.

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

Parameters

columnName
String

列的名称。The name of the column.

Returns

String

错误说明的文本。The text of the error description.

Examples

下面的示例为指定的 DataRow设置错误说明。The following example sets an error description for a specified 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

Remarks

使用 SetColumnError 方法设置列错误。Use the SetColumnError method to set column errors.

若要确定列集合是否存在任何错误,请使用 HasErrors 方法。To determine whether any errors exist for the columns collection, use the HasErrors method. 因此,您可以使用 GetColumnsInError 方法来检索所有包含错误的列。Consequently, you can use the GetColumnsInError method to retrieve all the columns with errors.

若要清除列集合的所有错误,请使用 ClearErrors 方法。To clear all errors for the columns collection, use the ClearErrors method.

See also

GetColumnError(DataColumn)

获取指定 DataColumn 的错误说明。Gets the error description of the specified 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

Parameters

column
DataColumn

一个 DataColumnA DataColumn.

Returns

String

错误说明的文本。The text of the error description.

Examples

下面的示例为指定的 DataRow设置错误说明。The following example sets an error description for a specified 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

Remarks

使用 SetColumnError 方法设置列错误。Use the SetColumnError method to set column errors.

若要确定列集合是否存在任何错误,请使用 HasErrors 方法。To determine whether any errors exist for the columns collection, use the HasErrors method. 因此,您可以使用 GetColumnsInError 方法来检索所有包含错误的列。Consequently, you can use the GetColumnsInError method to retrieve all the columns with errors. 或者,DataTableGetErrors 方法返回所有包含错误的行。Alternatively, the GetErrors method of the DataTable returns all rows with errors.

若要清除列集合的所有错误,请使用 ClearErrors 方法。To clear all errors for the columns collection, use the ClearErrors method.

See also

GetColumnError(Int32)

获取由索引指定的列的错误说明。Gets the error description for the column specified by index.

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

Parameters

columnIndex
Int32

列的从零开始的索引。The zero-based index of the column.

Returns

String

错误说明的文本。The text of the error description.

Exceptions

columnIndex 参数超出范围。The columnIndex argument is out of range.

Examples

下面的示例为指定的 DataRow设置错误说明。The following example sets an error description for a specified 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

Remarks

使用 SetColumnError 方法设置列错误。Use the SetColumnError method to set column errors.

若要确定列集合是否存在任何错误,请使用 HasErrors 方法。To determine whether any errors exist for the columns collection, use the HasErrors method. 因此,您可以使用 GetColumnsInError 方法来检索所有包含错误的列。Consequently, you can use the GetColumnsInError method to retrieve all the columns with errors.

若要清除列集合的所有错误,请使用 ClearErrors 方法。To clear all errors for the columns collection, use the ClearErrors method.

See also

Applies to