我有一个strored PROC,当与特定的一组中的参数,返回称为以下消息 -如何获得通过返回的所有消息错误存储过程:
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "abc" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "pqr" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "xyz" could not be bound.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'Name'.
Msg 50000, Level 16, State 1, Procedure ErrorHandlerProc, Line 218
Error Processing Request [ApplicationError]
我感兴趣的最后一行因为该误差是其中一个是要显示给用户
Error Processing Request [ApplicationError]
然而,当我CATC SqlExceltion,该消息属性只包含第一行即
The multi-part identifier "abc" could not be bound.
如何获取完整的错误并向用户显示。
请注意,我无法更改存储的proc。
更新
的SqlException.Errors
集合只包含一个条目是由SP返回的第一道防线。 InnerException
为空,其他属性如Data
或StackTrace
不返回所需的信息。
你能展示你的代码和你的try/catch吗?检查catch中的异常对象的属性,如stacktrace和InnerException –
在调试过的sp中不应该有这些类型的错误。这些都与坏的语法有关,应该在用户看到之前就解决。 – HLGEM
@HLGEM - 同意。但是有时候你所能做的只是与你所拥有的一起工作:)。 –