How to pass a Query String parameter to a Reporting Services Report

Navigate to the ReportServer website. You will see a list of folders. Open the folder with your report in it. Find the report you want and open it. The screen will come up and prompt you for parameters. Let’s say that your report needs a CustomerID. Simply ad this as a querystring value to the URL “&CustomerID=1516″ and refresh the page. If you pass all of the required parameters to the report it will run automatically.

Alternatively if you are using the ReportViewer Control in VS2005 you:

1. Reference the Microsoft.Reporting.WebForms namespace
2. Create a collection of ReportParameters
3. Create the individual paramenters
4. Pass the parameters to the SetParameters() function of the ReportViewer.

using Microsoft.Reporting.WebForms;

List<ReportParameter> parms = new List<ReportParameter>();

parms.Add(new ReportParameter(“CustomerID”, 1516));

ReportViewer1.ServerReport.SetParameters(parms);

2 Responses to How to pass a Query String parameter to a Reporting Services Report

  1. I added the following code

    protected void ReportViewer1_Load(object sender, EventArgs e)
    {
    List parms = new List();

    parms.Add(new ReportParameter(“NIM”,Request.QueryString["NIM"]));

    ReportViewer1.LocalReport.SetParameters(parms);
    }

    but i get this error

    An error has occurred during report processing.
    ObjectDataSource ‘ObjectDataSource1′ could not find a non-generic method ‘GetMasterNilaiByNIM’ that has no parameters

    can you help me?

  2. It may not recognize your parameters because your list needs to be of type Microsoft.Reporting.WebForms.ReportParameter

Leave a Reply