DataRow.GetColumnError 方法

定义

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

重载

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

参数

columnName
String

列的名称。The name of the column.

返回

String

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

示例

下面的示例为指定的设置了错误说明 DataRowThe 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

注解

使用 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.

另请参阅

适用于

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

参数

返回

String

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

示例

下面的示例为指定的设置了错误说明 DataRowThe 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

注解

使用 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. 另外, GetErrors 的方法将 DataTable 返回所有包含错误的行。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.

另请参阅

适用于

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

参数

columnIndex
Int32

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

返回

String

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

例外

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

示例

下面的示例为指定的设置了错误说明 DataRowThe 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

注解

使用 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.

另请参阅

适用于