我有一個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 - 同意。但是有時候你所能做的只是與你所擁有的一起工作:)。 –