views:

236

answers:

2

Hi,

I am calling a stored procedure through LINQ-to-SQL (yes, I know it's deprecated). I am getting back an error, but the IExecuteResult only seems to be able to provide me with a number, when I would like the full string error description (like what you would get if you executed the SQL by hand in SQL Management Studio). Alternatively, is there somewhere I can find this information logged? I have looked through the Management/Log stuff in the database and it only seems to hold login and sync information.

Thanks!

A: 

Some of these errors may have been logged into the SQL Server Log. For the rest, you might have to use the SQL Profiler and turn on one of the templates that displays errors and exceptions.

Alternatively, if you can reproduce the error, you could write some ADO.NET code to execute the same SP with the same parameters, then catch the SqlException that results. It will have all the error detail you could want, including a list of errors if there was more than one. You could also trap the information messages that may come back (PRINT statements, etc.)

John Saunders
So, no SQL exceptions are/can be thrown from the stored procedure? Something I can handle more appropriately on the .NET side? (other than returning some error code in the sp, of course)
Rodger Cooley
I said, "Alternatively, if you can reproduce the error, you could write some ADO.NET code to execute the same SP with the same parameters, then catch the SqlException that results."
John Saunders
OK, I am unfamiliar with the SQL profiler. I assumed it was a tool only for the SQL Server side.I'll look into that method some more. Thanks for the heads up.
Rodger Cooley
I'm not sure you're reading what I'm writing. I said nothing about SQL Profiler.
John Saunders
A: 

i was barking up the wrong tree. the SP wasn't returning anything :) thanks for the tip on the profiler though, I had never looked at that before!

evilfred