2015-02-06 44 views
0

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

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

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

现在,我修改了代码,使用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正常工作与以前的方法(调用报告没有的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() 

参数在RDL

enter image description here

回答

0

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

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

+0

请问为什么当我使用url方法(不使用reportviewer)时它工作正常? – Lijo 2015-02-09 14:54:25

+0

您能否告诉我您评论的区块是否有效? (将单个值设置为“rpCountID”参数而不是多个)。此外,请尝试对每个值使用“rpCountID.Values.Add”,而不是一次使用“rpCountID.Values.AddRange”。它工作吗? 顺便说一句,我仍然会确保** all **您应用于参数的值确实存在于数据集中。从我的经验来看,单一的价值混淆了整个事物是很常见的。 – 2015-02-09 16:20:42

+0

既然你提到过,当使用url方法时,你只传递一个单一的值,我的猜测是这个参数不接受这个值,因为你分配它们的方法,或者是因为有一个单独的值是无效的。 – 2015-02-09 16:42:09

0

ReportParameter rptParameter = default(ReportParameter); rptParameter = new ReportParameter(“放置参数名称”,“这里放置从数据库获取的列名/值”);

rptViewer1.LocalReport.SetParameters(rptParameter);