I am trying to test some exceptions in my project and one of the Exceptions I catch is SQlException.
It seems that you can\'t go new SqlException(
Not sure if this helps, but seems to have worked for this person (pretty clever).
try
{
SqlCommand cmd =
new SqlCommand("raiserror('Manual SQL exception', 16, 1)",DBConn);
cmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
string msg = ex.Message; // msg = "Manual SQL exception"
}
Found at: http://smartypeeps.blogspot.com/2006/06/how-to-throw-sqlexception-in-c.html