How do you get full error information for a stored

2019-08-27 20:51发布

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!

2条回答
一夜七次
2楼-- · 2019-08-27 21:41

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.)

查看更多
够拽才男人
3楼-- · 2019-08-27 21:43

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!

查看更多
登录 后发表回答