DataRow.GetColumnsInError Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets an array of columns that have errors.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

public DataColumn[] GetColumnsInError()

Return Value

Type: System.Data.DataColumn[]

An array of DataColumn objects that contain errors.

The GetColumnsInError lets you reduce the number of DataColumn objects that must be processed for errors by returning only those columns that have an error. Errors can be set to individual columns with the SetColumnError method. To further reduce the number of processing, examine the HasErrors property of the DataRow class to determine whether a DataRow has errors before invoking GetColumnsInError.

Use the ClearErrors method to clear all errors on the row. This includes the RowError.

The following example uses the HasErrors to look for errors. If the row has errors, the GetColumnsInError method returns the array of columns with errors that can then be resolved. The ClearErrors method is then called to clear all errors.

private void GetAllErrs(DataRow row)
    // Declare an array variable for DataColumn objects.
    DataColumn[] colArr; 
    // If the Row has errors, check use GetColumnsInError.
        // Get the array of columns in error.
        colArr = row.GetColumnsInError();
        for(int i = 0; i < colArr.Length; i++)
            // Insert code to fix errors on each column.
        // Clear errors after reconciling.

.NET Framework
Available since 1.1
Return to top