|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to tell if a timeout exception occuresIf 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? I suggest you check SqlException.Number. However, I don't know the
error number for connection timeout, you may need to test to see. 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. > > 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. >> >> 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. > >> > >> > > > |
|||||||||||||||||||||||