views:

40

answers:

2

What is the difference between SqlException and SqlExecutionException?

I understand that SqlException is an exception (or warning) thrown by SqlServer itself.

But in what cases the SqlExecutionException is thrown?

Why it is defined under System.Web.Management namespace?

A: 

SqlException is a generic exception in the System.Data.SqlClient class. It represents a problem occurring during the execution of some command against a SQL Server database from the SqlClient class.

SqlExecutionException is part of the management and health monitoring set of classes. It is used when a problem occurs during the installation or removal of a service against a SQL Server database used by the SqlServices class.

Thomas
A: 

They are in different namespsaces and are thrown by different classes.SqlException is in the System.Data.SqlClient namesspace and is thrown by classes in that namespace. SqlExecutionException is in the System.Web.Management namesspace and is thrown by classes in that namespace. You would not want classes within the System.Web.Management namesapce to be throwing exceptions that exist within the System.Data.SqlClient namespace, that would be very confusing when debugging, so they created a new exception class.

Ben Robinson