How to pass Report parameter in ReportViewer Control


  • Hello Friends,

    I am using VS2005. how to pass the Report parameter in the reportviewer control? I am using ther Remote mode for the report.

    till now i know that i can set the parameter is using the bellow method. This SetParamters method only accept the parameter like Microsoft.Reporting.WinForms.ReportParameter type.


    But can't findout how to pass that parameter in the method.

    please help me.


    Friday, November 11, 2005 11:35 AM


  • The VB snippet in the documentation is incorrect. The SetParameters method takes a collection (array, list etc) of ReportParameters, not a single ReportParameter object.

    Thursday, December 15, 2005 4:39 PM

All replies

  • Hi, you can do it like this:

    Dim objParameter As ReportParameter

    zobjParameter = New ReportParameter(strParamName, strParamValue)


    Hope this helps!

    Tuesday, November 22, 2005 3:49 PM
  • A small correction...

    Dim objParameter As ReportParameter

    zobjParameter = New ReportParameter(strParamName, strParamValue)



    Tuesday, November 22, 2005 3:51 PM
  • Hi,

    If i try to use the same code, it is showing the following error:

    Value of type "ReportParameter" cannot be converted to One-dimensional array.

    Any idea/solution.

    Thanks in advance.

    Thursday, December 15, 2005 11:58 AM
  • The VB snippet in the documentation is incorrect. The SetParameters method takes a collection (array, list etc) of ReportParameters, not a single ReportParameter object.

    Thursday, December 15, 2005 4:39 PM
  • Thanks for reply

    I have used like the following.

    Microsoft.Reporting.WinForms.ReportParameter rprameter = new Microsoft.Reporting.WinForms.ReportParameter(paraName, paraValue);

    this.rvReportViewer.ServerReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter[] {rprameter});

    and wroks fine. Now I need to pass null/Balnk value for the report. I have also set the property in report parameter to accept the Null and Blank value. But through codding it is not working.





    Wednesday, December 28, 2005 1:01 PM
  • You can do the following:


    parameters[0]  = new ReportParameter(key,new string[] {null});



    • Proposed as answer by Sarang Agre Friday, March 04, 2011 5:32 AM
    Tuesday, August 29, 2006 8:13 PM
  • I can't seem to get that to work in VB.  Still gives the error 'Paramater cannot be Null'.  Any ideas on making that work in VB?
    Friday, September 22, 2006 7:52 PM
  • could it be because of your report parameter setting in report designer ?
    Monday, September 25, 2006 1:19 AM
  • Has anyone figured out how to pass a null value yet? This code:

    parameters(0) = New ReportParameter("X", New String(Nothing))

    passes and empty string, not a null value.

    Monday, November 13, 2006 6:13 AM
  • Never mind. I figured it out. Just write this:

    parameters(0) = New ReportParameter("X")

    Monday, November 13, 2006 6:44 AM
  • I've used SSRS only but now I need to develop a report in a c# application and this is very confusing.  There is a "Find" option at the top of the report viewer control, though do not know where this is coded. 

    How can I just add a drop-down box or something to allow the user to select from a list of values (parameters)?

    Monday, November 13, 2006 4:31 PM
  • If you have a parameter defined in the report itself, and have the report viewer control set up to display parameters, it is all taken care of for you.
    Monday, November 13, 2006 9:13 PM
  • I ended up populating the comboBox separately and passing the selected value to the report:

         private void frmRptPaintSysList_Load(object sender, EventArgs e)

            private void populateComboBox()
                OleDbConnection cnn = new OleDbConnection(strCnn);
                OleDbDataReader dr = null;
                    string sSQL = "SELECT DISTINCT paintsys_code FROM paintsys ORDER BY paintsys_code";
                    OleDbCommand cmd = new OleDbCommand(sSQL, cnn);
                    dr = cmd.ExecuteReader();
                    if (dr != null)
                        while (dr.Read())
                catch (Exception ex)
                    throw ex;
                    if (dr != null)

            private void cboPaintSysReport_SelectedIndexChanged(object sender, EventArgs e)
                this.paintsysTableAdapter.FillByCode(this.usmDataSet_paintsys.paintsys, cboPaintSysReport.Text);



    Wednesday, November 15, 2006 5:04 PM
  • Hi!

    I'd like to know if I can pass a datasource as a parameter or better, if a datasource can be set for a report dinamically. The reason is that we're generating an xml dinamically and we would like to use this xml as our datasource. Is this possible?

    Thanks in advance!!! :)

    Monday, December 11, 2006 5:37 PM
  • Perfect answer by MaridiaH!!!



    Thursday, January 17, 2008 6:52 PM
  • I need to access a reportviewer page from a 2008 project.  That part works fine. The question I need answered is that I have parameters I need to pass from a 2003 project over to my 2008 project.  What do I need to do to get these 2003 parameters over to my 2008 project?


    Thursday, May 22, 2008 7:22 PM