AFAIK, the 'Procedure' property is available specifically for exceptions
that are of type SqlException, and it tells you the name of the SQL Server
stored procedure that threw an exception (perhaps other exception types have
a 'Procedure' as well - but not "otherwise uncategorized" exceptions).
Here is a snippet I have in my exception logging routine that writes out the
information. It tells me the name of the specific SQL Server stored
procedure that choked (this is the 'Procedure' you are asking about) and the
specific line number etc. very helpful to have this info:
if (exIncoming is SqlException) {
SqlException e = (SqlException) exIncoming;
//Exception Type
MyWriter.WriteElementString(@"ExceptionType", "SqlException");
// Exception Details
for (int i=0; i < e.Errors.Count; i++) {
MyWriter.WriteStartElement(@"ExceptionDetails");
MyWriter.WriteElementString(@"Message",
HttpUtility.HtmlEncode(e.Errors[i].Message));
MyWriter.WriteElementString(@"LineNumber",
HttpUtility.HtmlEncode(e.Errors[i].LineNumber.ToString()));
MyWriter.WriteElementString(@"Procedure",
HttpUtility.HtmlEncode(e.Errors[i].Procedure));
MyWriter.WriteElementString(@"SQLErrorNumber",
HttpUtility.HtmlEncode(e.Errors[i].Number.ToString()));
MyWriter.WriteElementString(@"SQLServerName",
HttpUtility.HtmlEncode(e.Errors[i].Server));
MyWriter.WriteElementString(@"Provider",
HttpUtility.HtmlEncode(e.Errors[i].Source));
MyWriter.WriteElementString(@"SQLStateValue",
HttpUtility.HtmlEncode(e.Errors[i].State.ToString()));
MyWriter.WriteEndElement(); // End Exception Details
}
}
HTH !
"Denise" <De****@discussions.microsoft.com> wrote in message
news:10**********************************@microsof t.com...
I am trying to implement database error logging in my asp.net application.
When I inspect the exception variable, I see that there is a property
called
'procedure' which I believe is the procedure or fucntion that caused the
error. How can I get at that variable to write it to my error log?
Thanks,
Denise