I have a problem where i want to show specific Exception Errors inside my reports(making life easier for the guy who has to fix things if they are borken).
I want my SQLexception
Not allowed to embed images(SQL)
and my SSRS exception
Not allowed to embed images(SSRS)
to both show the SQL exception message.
Does anybody have a clue how i can fix this?
so far I have only hit a wall
First, you need to wrap the SQL in a try ... catch
block ( see here ). This gives you control over what happens when the SQL throws an error and allows you to see the Error Message ( see here ).
In order for you to be able to display the error in SSRS, you have to still return a SELECT
statement with the same columns you would have normally. This is because SSRS needs to know the column names ahead of time. So add a column to your original dataset like so:
SELECT Col1, Col2, ... , NULL as ERROR_MESSAGE
And then add this in your catch
block:
SELECT NULL AS Col1, NULL as Col2, ... , ERROR_MESSAGE() as ERROR_MESSAGE
Then, in the report, you can check the Max(Fields!.ERROR_MESSAGE.Value)
to determine if you should display the error message in that column or regular data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.