Home All Groups Group Topic Archive Search About

How to tell if a timeout exception occures

Author
9 Mar 2006 12:59 AM
Jeremy Chapman
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?

Author
9 Mar 2006 9:00 AM
Truong Hong Thi
I suggest you check SqlException.Number. However, I don't know the
error number for connection timeout, you may need to test to see.
Author
9 Mar 2006 2:47 PM
MrSmersh
if( sqlException.Number == -2 && sqlException.Class == 10 )
for a normal timeout this is what you get

Show quote
"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.
>
>
Author
9 Mar 2006 4:59 PM
Jeremy Chapman
Thanks.  Are these numbers defined somewhere in the framework, because I
can't find -2 documented there or in the sql documentation.


Show quote
"MrSmersh" <MrSme***@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.
>>
>>
Author
10 Mar 2006 9:25 AM
MrSmersh
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.


Show quote
"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" <MrSme***@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.
> >>
> >>
>
>
>

AddThis Social Bookmark Button