I have an ASP.Net application with the following code:
try { sql = new SqlProc("prcCustomerAgeSelect", SqlProc.InParam("@DateFrom", SqlDbType.DateTime, 8, _OrderDateFrom), SqlProc.InParam("@DateTo", SqlDbType.DateTime, 8, _OrderDateTo), sql.Command.CommandTimeout = 1; dt = sql.ExecuteTable(); } catch (SqlException ex) { Filter.ErrorMessage = "Please narrow your search criteria."; }
Note the line:
sql.Command.CommandTimeout = 1;
Which causes a SqlException to be thrown (for testing).
I would have thought that the catch block would catch this exception, but it doesn't. Instead, I get:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
[SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.]
Why doesn't it catch it?? Am I using the wrong type? What am I missing here?
Thanks in advance!!
-Ev
It sounds like what you're seeing isn't a SqlException.
It's possible that SqlProc is itself catching SqlExceptions, extracting some information from them, then throwing new exceptions of a different type (embedding some of the original info in the new exception's message).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With