OdeToCode IC Logo


Friday, October 22, 2004

Question came in today about the SetReportParameters web service method of Reporting Services.

The name SetReportParameters is a bit misleading, and the documentation isn’t extremely clear. The method does not pass parameters to a report for rendering. Instead, the method has the same effect as modifying the parameter properties in the report designer. You can programmatically set valid values and prompt strings, etc. SetReportParameters is more of a “design time” method.

When SSRS goes to render a report, the parameter values come from one of three sources.

First, there could be a default parameter value specified in the report definition. If a default value exists SSRS will use the value, but you can override the default by passing a new parameter value using one of the techniques in the second source of parameter values.

The second source of a parameter value depends on how you access the Report Server. With URL access, you can pass a parameter value in the query string (&ParamName=Europe). If you are using the web service, then the ReportingService.Render web method accepts an array of type ParameterValue. The documentation online includes an example of how to pass the parameter values.

Finally, if there is a parameter left that does not have a default value, and you did not specify a value in the query string or in the web service call, SSRS has no choice but to prompt the user to enter a value. If you have hidden the parameter input area or the toolbar, the Report Server will throw an exception, otherwise you’ll see the TextBox and DropDownList controls appear for the user to select values.

Hope this helps…

Mike Friday, October 22, 2004
Hi Scott
<br>Not pretty but gets the concept across – basically, set the default value of a param as if you where in design mode and then call report.
<br>ReportingService rService = new ReportingService();
<br>rService.Credentials = System.Net.CredentialCache.DefaultCredentials;
<br>ReportParameter[] parameters = new ReportParameter[1];
<br>parameters[0] = new ReportParameter();
<br>parameters[0].DefaultValues = new string[1];
<br>parameters[0].Name = &quot;DEVICECODE&quot;;
<br>parameters[0].DefaultValues[0] = TextBox1.Text;
<br>rService.SetReportParameters(&quot;/dialcodes/Report1&quot;, parameters);
<br>//RUN REP
<br>ReportViewer1.ServerUrl = &quot;http://localhost/reportserver&quot;;
<br>ReportViewer1.ReportPath = &quot;/Dialcodes/Report1&quot;;
<br>ReportViewer1.Zoom = &quot;100&quot;;
elizabeth Wednesday, December 1, 2004
<br>Need to get the parameter value and the parameter name to pass to render method of reporting services from the parameterised report.
Scott Allen Wednesday, December 1, 2004
<br>Do you want to get the parameter value by prompting the users or some other means?
Vivian Monday, December 6, 2004
I am using URL passing parameter and user prompting method at the same time, coz some parameters need to be passed by URL, some of parameters need to be input by users. Thing is if the parameter is passed by URL and how I can make that parameter textbox hidden. Thanks a lot.
Scott Allen Tuesday, December 7, 2004
Vivian: I'll blog an answer very soon. Make sure you have reporting services service pack 1 installed.
Mark Milley Friday, October 7, 2005
Mike -

How would that technique work in an application with a heavy workload? If two users simultaneously accessed the report with different default parameters, wouldn't this cause an exception, or at least, unexpected behavior?
Raj Tuesday, March 28, 2006
What is limit on the text size of parameter if we use SSRS web service?

I have a report requirement which needs to take atleast 5000 chartecters text as parameter(comma delimited values).

scott Tuesday, March 28, 2006
I'm sure 5000 is reasonable. I'm not aware of a hard limit, although asp.net is configured to reject requests over 4 MB as a default.
Comments are closed.