O'Reilly logo

A Programmer's Guide to .NET by Alexei Fedorov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

12.9. Processing errors

The DataAdapter class throws generic exceptions when problems occur. To obtain a descriptive error message for each fault in a row and column in any table in a DataSet, we use the following technique.

  • Check the HasError property to see if any of the tables in the DataSet contain errors.

  • If no errors are detected in the DataSet, we can safely proceed with the Update.

  • If errors are detected in the DataSet, we use the GetErrors method to obtain the rows that contain the errors.

  • Once we have determined which rows contain the errors, we use the GetColumnError(DataColumn ) method to determine the incorrect columns for each row with errors.

The following example illustrates the technique described above:

 If (Not DS.HasErrors) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required