Using RowError of the DataSet

To be much more efficient in responding to individual row error conditions, you can add error information to the row itself (even at the column level). The DataRow object allows you to do this by providing a RowError property for each row in the DataSet. As data rows are processed (for example, when updating them), you can set the RowError property for a row to indicate that it has an error. Then, simply use the HasErrors property to determine whether any error information has been added to any of the rows in the dataset. You can use the GetErrors method to return and examine only the rows with errors. It's all very slick.

Listing 13.3 is a short piece of code that adds a RowError condition to a particular row in ...

Get Sams Teach Yourself ADO.NET in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.