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.

this.reportViewer1.ServerReport.SetParameters().

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

please help me.

Nilay





Answer this question

How to pass Report parameter in ReportViewer Control

  • Amaltea

    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.



  • vitfrasson

  • GordonBeMe

    You can do the following:

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


  • Lee Evans

    Hi, you can do it like this:

    Dim objParameter As ReportParameter

    zobjParameter = New ReportParameter(strParamName, strParamValue)

    Me.objReportViewer.ServerReport.SetParameters(zstrParameter)


    Hope this helps!
    Alejandro.


  • A. Jason

    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.
  • gmitchell7

    A small correction...

    Dim objParameter As ReportParameter

    zobjParameter = New ReportParameter(strParamName, strParamValue)

    Me.objReportViewer.ServerReport.SetParameters(zobjParameter)

    Alejandro.


  • BMcK

    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

  • Dhanhamsan Gunalan

    Never mind. I figured it out. Just write this:

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


  • VB_Newbie

    could it be because of your report parameter setting in report designer
  • patmur

    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.

     

    Thanks

    Nilna

     



  • Anver

    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.


  • DataWranglerAtBellSouth

    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)


  • Sean Riddle

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


  • GChao

    I ended up populating the comboBox separately and passing the selected value to the report:

    private void frmRptPaintSysList_Load(object sender, EventArgs e)
    {
    populateComboBox();
    this.paintsysTableAdapter.Fill(this.usmDataSet_paintsys.paintsys);
    this.reportViewerPaintSysList.RefreshReport();
    }

    private void populateComboBox()
    {
    OleDbConnection cnn = new OleDbConnection(strCnn);
    OleDbDataReader dr = null;
    try
    {
    cboPaintSysReport.Items.Clear();
    string sSQL = "SELECT DISTINCT paintsys_code FROM paintsys ORDER BY paintsys_code";
    cnn.Open();
    OleDbCommand cmd = new OleDbCommand(sSQL, cnn);
    dr = cmd.ExecuteReader();
    if (dr != null)
    {
    while (dr.Read())
    {
    cboPaintSysReport.Items.Add(dr["paintsys_code"]);
    }
    }
    }
    catch (Exception ex)
    {
    throw ex;
    }
    finally
    {
    if (dr != null)
    {
    dr.Close();
    }
    cnn.Close();
    }
    }

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


  • How to pass Report parameter in ReportViewer Control