【问题标题】:Parameter is missing a value SSRS参数缺少值 SSRS
【发布时间】:2023-03-24 13:37:02
【问题描述】:

我有一个带有两个参数的SSRS 2005 报告。 CountID 参数是一个查询值 (From query)。我使用以下方法从 ASP.Net 2.0 调用此报告,它工作正常。

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

请注意,我们只从 ASPX 页面为参数 CountID 传递一个字符串值。仍然可以正常工作。

现在,我使用以下代码修改了代码以使用 reportviewercontrol。但是当报告呈现时,它会显示“'CountID' 参数缺少值”。我已经提到了以下两个帖子 - 但它没有帮助。知道如何使它工作吗?

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

注意:我知道如果我将 CountID 设为 non-queried 或将其设为文本框将解决问题。但是我需要在不更改rdl 文件的情况下使代码正常工作。 [原因是 rdl 在以前的方法中工作正常(在没有报告查看器的情况下调用报告)]

代码

   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()

RDL 中的参数

【问题讨论】:

    标签: c# asp.net .net vb.net reporting-services


    【解决方案1】:

    通过将“可用值”设置为“来自查询”,您实际上限制了 SSRS 将接受的值。我相信如果你传递一个不在列表中的值,它会忽略它,然后你会得到“缺失值”错误。

    您是否确定您传递的值存在于“Counts”数据集中?

    【讨论】:

    • 你能告诉我为什么当我使用 url 方法(不使用 reportviewer)时它工作得很好吗?
    • 你能告诉我你评论的块是否有效吗? (将单个值设置为“rpCountID”参数而不是多个)。此外,请尝试对每个值使用rpCountID.Values.Add,而不是同时对所有值使用rpCountID.Values.AddRange。它有效吗?顺便说一句,我仍然会确保您应用于参数的 all 值确实存在于数据集中。根据我的经验,单个值会搞砸整个事情是很常见的。
    • 既然你提到当使用 url 方法时你只传递一个值,我的猜测是参数不接受值是因为你分配它们的方法,或者因为有一个单个值无效。
    【解决方案2】:

    ReportParameter rptParameter = default(ReportParameter); rptParameter = new ReportParameter("此处放置参数名称", "此处放置从数据库中获取的列名称/值");

    rptViewer1.LocalReport.SetParameters(rptParameter);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-08
      • 1970-01-01
      • 1970-01-01
      • 2016-02-14
      • 2011-02-12
      • 1970-01-01
      相关资源
      最近更新 更多