If a time out occures an SqlException is thrown, but how can I
programatically tell if the SqlException is a timeout error vs some other
type?

Re: How to tell if a timeout exception occures by Truong

Truong
Thu Mar 09 03:00:30 CST 2006

I suggest you check SqlException.Number. However, I don't know the
error number for connection timeout, you may need to test to see.


Re: How to tell if a timeout exception occures by MrSmersh

MrSmersh
Thu Mar 09 08:47:28 CST 2006

if( sqlException.Number == -2 && sqlException.Class == 10 )
for a normal timeout this is what you get

"Truong Hong Thi" wrote:

> I suggest you check SqlException.Number. However, I don't know the
> error number for connection timeout, you may need to test to see.
>
>

Re: How to tell if a timeout exception occures by Jeremy

Jeremy
Thu Mar 09 10:59:33 CST 2006

Thanks. Are these numbers defined somewhere in the framework, because I
can't find -2 documented there or in the sql documentation.


"MrSmersh" <MrSmersh@discussions.microsoft.com> wrote in message
news:87C17E73-E7DB-4A38-8A31-BD2062420C8E@microsoft.com...
> if( sqlException.Number == -2 && sqlException.Class == 10 )
> for a normal timeout this is what you get
>
> "Truong Hong Thi" wrote:
>
>> I suggest you check SqlException.Number. However, I don't know the
>> error number for connection timeout, you may need to test to see.
>>
>>



Re: How to tell if a timeout exception occures by MrSmersh

MrSmersh
Fri Mar 10 03:25:26 CST 2006

Some of these (Iâ??ve tried to classify the most common exceptions) are in the
SQL Server documentation.
But for some is just plain debugging you got the exception look at the
message and you know now when occurs.
BTW: these are the values you going to get when using the native database
provider, for ODBC there are other conditions.


"Jeremy Chapman" wrote:

> Thanks. Are these numbers defined somewhere in the framework, because I
> can't find -2 documented there or in the sql documentation.
>
>
> "MrSmersh" <MrSmersh@discussions.microsoft.com> wrote in message
> news:87C17E73-E7DB-4A38-8A31-BD2062420C8E@microsoft.com...
> > if( sqlException.Number == -2 && sqlException.Class == 10 )
> > for a normal timeout this is what you get
> >
> > "Truong Hong Thi" wrote:
> >
> >> I suggest you check SqlException.Number. However, I don't know the
> >> error number for connection timeout, you may need to test to see.
> >>
> >>
>
>
>