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.

傳回

錯誤描述的文字。The text of the error description.

範例

下列範例會針對指定的 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

備註

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

參數

傳回

錯誤描述的文字。The text of the error description.

範例

下列範例會針對指定的 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

備註

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

另請參閱

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.

傳回

錯誤描述的文字。The text of the error description.

例外狀況

columnIndex 引數超出範圍。The columnIndex argument is out of range.

範例

下列範例會針對指定的 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

備註

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

另請參閱

適用於