Handling Time Out SQLExceptions

  • Thread starter Thread starter Drew
  • Start date Start date
D

Drew

I am updating some tables and once in while the updates
are timing out. When a SQLException is thrown I catch it
and would like to check it if it is a TIME_OUT exception
and if it is try to do the update at a later time.

I am catching the exception and I get the error number.
But the only way to find out if the execution timed out is
by looking up the exception message for "Timeout expired."
phrase in it.

Is there a way to differentiate the time out error from
the others without having to lookup the exception message.
In C++ code I remember doing something like if number =
SQL_TIME_OUT. Is there any similar option in ADO.NET.

Thanks and appreciate your help.
Drew
 
The SqlException object has a bevy of information including the Message,
Number, and State. I would look there for a tell-tale number.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Yes, I agree. The Message, Number and state provide
adequate information.

What I do now is examine the message for time out entry in
the message body and it works.
In C++, I remember doing something to like comparing the
sql exception errors numbers with defines SQL_ERROR,
SQL_SUCCESS_WITH_INFO, SQL_TIMEOUT.
I was looking to find out if something like that exists in
ADO.NET.

Thanks,
Drew
 
Hi Drew,
Did you put the SQLexeption on a redirect page, that is quiet easy for
testing?
Cor
 
This is in a windows service. A web service gets the data
and dumps them into some intermediate cache table. This
windows service monitors the cache table for new entries
and process the data and updates other tables.

Some times updates timeout, as of now I am handling them
by looking for Timeout expired." in the message of the
SQLexception. Instead I was looking for an easy way to
compare the SQLException number to some define like
SQL_TIMEDOUT for determining if the call to update timed
out. If the time out occured I will make the entry as
timed out and retry it at a later time.

Thanks,
Drew
 
Drew,
When I saw the other answer I saw I did make a mistake and did read to much.
But I thought making a correction is even worse because I had no answer
Sorry
Cor
 
Back
Top