Data Access Exceptions

Topics: Data Access Application Block
Mar 7, 2007 at 7:29 PM
This is a really easy question, but it has been bugging me for a while so I might as well ask: what exceptions do data access application block methods throw? As a specific example, what exceptions can SqlDatabase.ExecuteNonQuery() throw? I am assuming it only would throw SqlExceptions (like if I were to use a SqlCommand object), but have been unable to find any documentation to confirm this. I try to avoid using try{}catch(Exception){} blocks when I can and replace the "Exception" with more specific exception types.

Thanks.
Mar 12, 2007 at 4:18 PM
You will get SqlExceptions for particular database operations, but you could also get your standard argument checking exceptions like ArgumentException and ArgumentNullException, as well as InvalidOperationException if you try do something unsupported, etc.

If you have instrumentation turned on, you could receive some errors associated with it, too.

Regards,

Dave

_________________________

David Hayden
Microsoft MVP C#
Mar 12, 2007 at 8:10 PM

DavidHayden wrote:
You will get SqlExceptions for particular database operations, but you could also get your standard argument checking exceptions like ArgumentException and ArgumentNullException, as well as InvalidOperationException if you try do something unsupported, etc.

If you have instrumentation turned on, you could receive some errors associated with it, too.

Regards,

Dave

_________________________

David Hayden
Microsoft MVP C#


Thanks a lot, I had seen an InvalidOperationException but hadn't thought of the argument-related exceptions. That was just what I was looking for.