DataRow.GetColumnError 方法

定義

取得資料行的錯誤描述。

多載

GetColumnError(String)

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

GetColumnError(DataColumn)

取得指定 DataColumn 的錯誤描述。

GetColumnError(Int32)

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

GetColumnError(String)

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

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

C#
public string GetColumnError (string columnName);

參數

columnName
String

資料行名稱。

傳回

錯誤描述的文字。

範例

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

C#
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));
}

備註

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

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

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

另請參閱

適用於

.NET 9 和其他版本
產品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetColumnError(DataColumn)

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

取得指定 DataColumn 的錯誤描述。

C#
public string GetColumnError (System.Data.DataColumn column);

參數

傳回

錯誤描述的文字。

範例

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

C#
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));
}

備註

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

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

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

另請參閱

適用於

.NET 9 和其他版本
產品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetColumnError(Int32)

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

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

C#
public string GetColumnError (int columnIndex);

參數

columnIndex
Int32

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

傳回

錯誤描述的文字。

例外狀況

columnIndex 引數超出範圍。

範例

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

C#
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));
}

備註

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

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

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

另請參閱

適用於

.NET 9 和其他版本
產品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1