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…
Comments
<br>
<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>
<br>Cheers
<br>
<br>Mike
<br>
<br>----
<br>ReportingService rService = new ReportingService();
<br>rService.Credentials = System.Net.CredentialCache.DefaultCredentials;
<br>
<br>ReportParameter[] parameters = new ReportParameter[1];
<br>parameters[0] = new ReportParameter();
<br>parameters[0].DefaultValues = new string[1];
<br>parameters[0].Name = "DEVICECODE";
<br>parameters[0].DefaultValues[0] = TextBox1.Text;
<br>rService.SetReportParameters("/dialcodes/Report1", parameters);
<br>
<br>//RUN REP
<br>ReportViewer1.ServerUrl = "http://localhost/reportserver";
<br>ReportViewer1.ReportPath = "/Dialcodes/Report1";
<br>ReportViewer1.Zoom = "100";
<br>----
<br>Need to get the parameter value and the parameter name to pass to render method of reporting services from the parameterised report.
<br>
<br>
<br>
<br>Do you want to get the parameter value by prompting the users or some other means?
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?
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).
Thanks
Raj