简体   繁体   中英

Parameter is missing a value SSRS

I have a SSRS 2005 report with two parameters. The CountID parameter is a queried value ( From query ). I am calling this report from ASP.Net 2.0 using following approach and it works fine.

 window.location.href= strRepServer + strReport + "&rc:Parameters=false&rs:ClearSession=true&plantcd=" + strPlantCD + "&CountID=" + strCountID;

Note that we are passing only one string value from ASPX page for the parameter CountID. Still it works fine.

Now, I modified the code to use reportviewercontrol using following code. But when the report renders, it says “The 'CountID' parameter is missing a value”. I have referred following two posts – but it didn't help. Any idea how to make it work?

  1. Pass Multi value parameter to SSRS from UI
  2. Passing a Multi-value parameter to the ReportViewer control

Note: I understand that if I make the CountID as non-queried or making it as textbox will resolve the issue. But I need to make code working without changing the rdl file. [Reason being the rdl works fine with previous approach (calling report without reportviewer)]

CODE

   rvInvalidPackageSKUs.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote

   rvInvalidPackageSKUs.ServerReport.ReportServerUrl = New Uri("http://myserver/ReportServer/")
   rvInvalidPackageSKUs.ServerReport.ReportPath = "/MyFolder/SubFolder/MyReport"

   Dim rpPlant As New ReportParameter
   rpPlant.Name = "plantcd" 
   rpPlant.Values.Add("23")

   'Dim rpCountID As New ReportParameter
   'rpCountID.Name = "CountID"
   'rpCountID.Values.Add("1")

    Dim rpCountID As ReportParameter
    rpCountID = New ReportParameter("CountID")
    Dim valuesArray As String() = New String() {"x", "y", "z"}
    rpCountID.Values.AddRange(valuesArray)

    Dim paramList As New Generic.List(Of ReportParameter)
    paramList.Add(rpPlant)
    paramList.Add(rpCountID)

    rvInvalidPackageSKUs.ServerReport.SetParameters(paramList)
    rvInvalidPackageSKUs.ServerReport.Refresh()

Parameter in RDL

在此处输入图片说明

By setting "Available values" to "From query", you actually restrict the values that SSRS will accept. I believe that if you'll pass a value that is not in the list, it will just ignore it and then you'll get the "missing value" error.

Did you make sure that the value you're passing exists the "Counts" dataset?

ReportParameter rptParameter = default(ReportParameter); rptParameter = new ReportParameter("Here Put The Parametrs Name", "Here Put the Column Name/Value getting from Database");

rptViewer1.LocalReport.SetParameters(rptParameter);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM