Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parameter Validation on Reports

I'm new to SSRS, so I apologize if this question is too simple:

I have a report which accepts a parameter called "Amount". I want to constrain valid inputs to currency values >= 0, and pop open an error message if the user enters improper values.

I don't want to validate inputs in my stored procedure and throw exceptions, because SSRS displays a very generic "Query execution failed for 'someTable'" message to users who access the report from another machine, and my business does not want to turn on the "Enable Remote Errors" flag.

How do I add input validation to report parameters and notify users of bad input?

Yes, I've googled around, but haven't had much luck. Thanks in advance :)

like image 333
Juliet Avatar asked Jan 14 '09 17:01

Juliet


People also ask

How do you validate parameters?

For a subroutine expecting named parameters, you would do this: validate( @_ , { foo => 1, bar => 1, baz => 0 } ); This says that the "foo" and "bar" parameters are mandatory and that the "baz" parameter is optional. The presence of any other parameters will cause an error.

What are parameters in a report?

Parameters are one of the built-in collections that you can include in an expression in a report. Because expressions are used to define values throughout a report definition, you can use parameters to control report appearance or to pass values to related subreports or reports that also use parameters.

How do you pass a parameter to a report?

You can pass report parameters to a report by including them in a report URL. These URL parameters are not prefixed because they are passed directly to the report processing engine.

What is the main purpose of report parameter?

Report parameters allow you to control the report's content, to connect related reports, or to use them as arguments in functions.


1 Answers

Okay, how about this?

All you have in SSRS, really, is the SQL query and expressions in report fields.

Perhaps you could add a big, red text box at the top of the report for your error message, and give it an expression like '=IIf(Parameters!Amount.Value < 0, "Error: Invalid Amount", "")'.

Then go to your table's "Hidden" property and give it the expression "=Parameters!Amount.Value < 0"

You could also add into your query's where clause and add "AND @Amount >= 0" so you aren't fetching from the database when there's an error.

like image 96
Darcy Casselman Avatar answered Oct 03 '22 14:10

Darcy Casselman