Export (0) Print
Expand All

How to: Locate Rows that Have Errors

When working with individual columns and rows of data, there may be times when a record contains an error. You can Check the HasErrors property to determine if errors exist in a DataSet, DataTable, or DataRow.

To locate a row that has errors

  1. Check the HasErrors property to see if there are any errors in the dataset.

  2. If the HasErrors property is true, iterate through the collections of tables, then the rows to find the row with the error.

    private void FindErrors() 
    {
        if (dataSet1.HasErrors)
        {
            foreach (DataTable table in dataSet1.Tables)
            {
                if (table.HasErrors)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        if (row.HasErrors)
                        {
                            // Process error here.
                        }
                    }
                }
            }
        }
    }
    
Show:
© 2015 Microsoft