Läs på engelska Redigera

Dela via


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)

Gets the error description of the specified DataColumn.

GetColumnError(Int32)

Gets the error description for the column specified by index.

GetColumnError(String)

Source:
DataRow.cs
Source:
DataRow.cs
Source:
DataRow.cs

Gets the error description for a column, specified by name.

C#
public string GetColumnError(string columnName);

Parameters

columnName
String

The name of the column.

Returns

The text of the error description.

Examples

The following example sets an error description for a specified 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));
}

Remarks

Use the SetColumnError method to set column errors.

To determine whether any errors exist for the columns collection, use the HasErrors method. Consequently, you can use the GetColumnsInError method to retrieve all the columns with errors.

To clear all errors for the columns collection, use the ClearErrors method.

See also

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.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)

Source:
DataRow.cs
Source:
DataRow.cs
Source:
DataRow.cs

Gets the error description of the specified DataColumn.

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

Parameters

Returns

The text of the error description.

Examples

The following example sets an error description for a specified 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));
}

Remarks

Use the SetColumnError method to set column errors.

To determine whether any errors exist for the columns collection, use the HasErrors method. Consequently, you can use the GetColumnsInError method to retrieve all the columns with errors. Alternatively, the GetErrors method of the DataTable returns all rows with errors.

To clear all errors for the columns collection, use the ClearErrors method.

See also

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.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)

Source:
DataRow.cs
Source:
DataRow.cs
Source:
DataRow.cs

Gets the error description for the column specified by index.

C#
public string GetColumnError(int columnIndex);

Parameters

columnIndex
Int32

The zero-based index of the column.

Returns

The text of the error description.

Exceptions

The columnIndex argument is out of range.

Examples

The following example sets an error description for a specified 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));
}

Remarks

Use the SetColumnError method to set column errors.

To determine whether any errors exist for the columns collection, use the HasErrors method. Consequently, you can use the GetColumnsInError method to retrieve all the columns with errors.

To clear all errors for the columns collection, use the ClearErrors method.

See also

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.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