Using Reporting Services GetReportParameters web method

Wednesday, April 28, 2004

A question today on how to get the valid values for a report parameter via the web service API when a query specifies the valid values. (Whew - clunky sentence).

To do this you can use the GetReportParameters web method. First, be wary of a small bug in the documentation where the order of parameters are incorrect. Not a big problem with intellisense, though.


ReportingService rService = new ReportingService();
rService.Credentials = 
string historyID = null;
bool forRendering = true;
ParameterValue[] values = null;                                  
DataSourceCredentials[] credentials = null;
ReportParameter[] parameters;
parameters = rService.GetReportParameters
                        "/Northwind Reports/Report2",

This will give you back an array of ReportParameter objects. If a ReportParameter object has a set of valid values defined by a query, reporting services will run the query and populate the ValidValues property with ValidValue objects (only when ForRendering == true). If we wanted to dump the valid values for parameter[0]:

foreach(ValidValue v in parameters[0].ValidValues)
    Console.WriteLine(v.Label + " " + v.Value);

Note, if you have hierarchical parameters, where, for example, the set of valid values for parameters[1] depends on the value selected for parameters[0], you’ll need to initialize the ParameterValue array to get the valid values for parameters[1]. If you are doing this all from scratch this may mean multiple calls to GetReportParameters.

Rajesh Jagadeesan Tuesday, July 13, 2004
Hello sir,
<br>I tried exactly the same code, but when i executed the application, it gives the following error.
<br>System.Web.Services.Protocols.SoapException: The permissions granted to user 'DPA32W126\ASPNET' are insufficient for performing this operation.
<br>How do i correct this problem?
<br>Thankx in advance,
<br>Rajesh Jagadeesan
Scott Allen Tuesday, July 13, 2004
Hi Rajesh,
<br>You'll need to setup impersonation or run the ASP.NET application under an account with permissions to the report server (is it the same machine?)
<br>Here are some additional articles to help:
Moosa Tuesday, April 26, 2005
<br>I have been playing with Reporting Services for sometime now and it seems to work great so far. I am now trying to render these reports into a web application. I am using the web service to render them. However, when I try to pass my paramters, it gives an &quot;System.NullReferenceException: Object reference not set to an instance of an object.
<br>&quot; exception. The following is the code I am trying to use.
<br>ParameterValue[] parameters = new ParameterValue[3];
<br>parameters[0].Value = &quot;20055&quot;;
<br>parameters[1].Value = &quot;000047&quot;;
<br>parameters[2].Value = &quot;83&quot;;
<br>Can someone please help. It seems like I am not defining my paramters correctly.
Moosa Tuesday, April 26, 2005
Actually i got it fixed. it should be like this.
<br>ParameterValue p1 = new ParameterValue();
<br>p1.Name = &quot;&lt;parameter name&gt;&quot;;
<br>p1.Value = &quot;20055&quot;;
<br>ParameterValue p2 = new ParameterValue();
<br>p2.Name = &quot;&lt;parameter name&gt;&quot;;
<br>p2.Value = &quot;000047&quot;;
<br>ParameterValue p3 = new ParameterValue();
<br>p3.Name = &quot;&lt;parameter name&gt;&quot;;
<br>p3.Value = &quot;83&quot;;
<br>ParameterValue[] parameters = new ParameterValue[3];
<br>parameters[0] = p1;
<br>parameters[1] = p2;
<br>parameters[2] = p3;
Dalia Friday, April 21, 2006
I am getting Error The type or namespace name 'ReportParameter' could not be found (are you missing a using directive or an assembly reference?)

please help.
Scott Allen Friday, April 21, 2006
Do you have a using directive? Did you use "Add Web Reference" in Visual Studio?
Dali Friday, April 21, 2006
Yes, I did. Now I can assign the parameters but can't display the report?
Dinesh Monday, November 20, 2006

Thanks for this post but still i have some dobts..........
My problem is

I am using VS2003 and Sql server 2000 RS.

It a purely windows application. and i am using RE class file in stead of.....RS web services refrence.

My problem is .that i have listed all the reports on report server.

after selecting a report, it will show all the parameter names in first checklist box...and their corresponding values in another list box.

Now problem is that if suppose report has 4 parameters.....second parameter will be inabled after selecting first and same for third. i.e.their values depend upon first parameter to be passed.

first and 4 th will be independent.

my program is showing all the parameters in first check list and the value of first parameter in the second checklist.

now i want to select a value for first parameter then it will show related value for second parameter in the second list. but my program is showing first parameter value for all the if u know then tell me that how can i pass first parameter value so that it will fetch the values for others.

Thanks And Regards

Comments are closed.

My Pluralsight Courses

K.Scott Allen OdeToCode by K. Scott Allen
What JavaScript Developers Should Know About ECMAScript 2015
The Podcast!