Help - why does SqlException not list Procedure name on timeout?

N

n.phelge

When I have a timeout on invoking a stored procedure against SQL
Server, I have an exception returned that looks like the following:

{System.Data.SqlClient.SqlException}
System.SystemException: {"Timeout expired. The timeout period
elapsed prior to completion of the operation or the server is not
responding."}
_errors: {System.Data.SqlClient.SqlErrorCollection}
Class: 10
Errors: {System.Data.SqlClient.SqlErrorCollection}
LineNumber: 0
Message: "Timeout expired. The timeout period elapsed prior to
completion of the operation or the server is not responding."
Number: -2
Procedure: "ConnectionRead (WrapperRead())."
Server: ""
Source: ".Net SqlClient Data Provider"
State: 0

There no additional information in the Errors collection. The
description of SqlException.Procedure property is as follows:

Gets the name of the stored procedure or remote procedure call (RPC)
that generated the error.

Is there something I'm missing? I'm trying to put together some
generic logging capabilities, and I had expected that the SqlException
would always provide the name of the stored procedure in the Procedure
property.

Thanks in advance.
 
A

Aaron Bertrand [SQL Server MVP]

This relies on the message that comes back from SQL Server, which AFAIK does
not include the procedure name in the case of a timeout. If you have a
try{}catch(Exception e){} around a specific call, can't you append the name
of the procedure you tried to e.Message? No, it is neither ideal nor
elegant, but in an ideal world, you would fix the stored procedure so that
it doesn't time out in the first place. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top