Reputation: 9312
I have a strored Proc which, when called with a specific set to parameters, returns following messages -
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]
I am interested in the last line of error since that is the one which is to be show to the user
Error Processing Request [ApplicationError]
However when I catc SqlExceltion, the message property only contains the first line i.e.
The multi-part identifier "abc" could not be bound.
How can I get the complete error and show that to user.
Please note that I cannot change the stored proc.
Update
The SqlException.Errors
collection contains only one entry which is the first line returned by the sp. The InnerException
is null and other properties such as Data
or StackTrace
do not return required information.
Upvotes: 2
Views: 148
Reputation: 16032
Check the Errors
-property of the SqlException
. There you should find a list of SqlError
Objects with all the messages from the underlying provider.
Upvotes: 1