O'Reilly logo

Essential ADO.NET by Bob Beauchemin

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

3.10. Error Handling

If you need to handle only a single error, you can use the generic Exception class, which reports a single error message. Sometimes, databases return additional error information or a collection of errors. This is especially true of OLE DB, in which each provider can add information when using the service provider architecture. For this reason, SqlClient and OleDb each implements its own subclass of Exception, which can return a collection of errors.

The OleDb provider's OleDbException exposes an OleDbErrorCollection that is similar to the ADO's Errors collection (OLE DB's IErrorRecord). Each error contains an error message, the provider's native error, and an optional SQLState. The OleDbException is derived from InteropServices.ExternalException ...

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