DataRow.GetColumnsInError Method

Gets an array of columns that have errors.

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

public DataColumn[] GetColumnsInError ()
public DataColumn[] GetColumnsInError ()
public function GetColumnsInError () : DataColumn[]

Return Value

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 fdetermine whetherne if 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.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0