what is the best practice for issuing an error from ssrs?

db042190 1,516 Reputation points
2021-11-08T18:21:26.527+00:00

hi we are currently on 2014 enterprise and will be on 2019 enterprise in the coming months.

on at least 24 of our reports, there is a set of parameters called minimum balance and maximum balance. I can get into a long explanation about negatives meaning the customer owes us and positives meaning we owe him, but the bottom line for this question is that by definition zero is invalid for a min or max balance.

i suspect that is difficult if not impossible to control from ssrs. who knows. maybe there is a way to introduce an ssrs expression based function before the proc is run?

so we are thinking about either throwing an exception in the proc or returning one liners to our tablix's with the appropriate error. exceptions sound like the more appropriate way to go but then we wonder about the whole "enabling remote errors" thing being a prerequisite to the user understanding what he sees once we throw the exception.

can someone guide us on best practice? we dont enable remote errors right now and i dont think we will be doing that.

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,806 questions
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. db042190 1,516 Reputation points
    2021-11-10T14:59:16.053+00:00

    i tried a few things and have to conclude enabling remote errors is the best choice given how inexpensive a solution it is if you introduce a raise error in your proc. but see caveat in last paragraph,

    before coming to that conclusion, i tried introducing the vb expression based func you see below and then finding available real estate for a new textbox. And returning no rows (new predicate) in the proc in this situation. This is what zoehui has been recommending. My biggest problem with this is finding the available real estate for a new text box and not upsetting the delicate balance we often have with merge cells when saving to excel.

    the only surprise i've seen so far with enabling remote errors and raising your own error (even sev 18) in the proc is that if you don't also introduce the predicate in your proc's select to basically return nothing (like zoehui recommended), your proc actually runs thru the data anyway even though no resultset shows on your report. i dont think this was true before i enabled remote errors and raised sev 18 but i could be wrong. i think before, the raise error halted execution of the proc immediately.

    Function CheckBalanceParameters(p1 as Double, p2 as Double)
    Dim msg as String
    msg = ""
    
    If (p1 =0 or p2=0) Then                                         
    msg="INVALID BALANCE RANGE"
    End If
    
    Return msg
    End Function
    
    0 comments No comments