C# 参数缺少一个值SSRS

C# 参数缺少一个值SSRS,c#,asp.net,.net,vb.net,reporting-services,C#,Asp.net,.net,Vb.net,Reporting Services,我有一份带有两个参数的SSRS 2005报告。CountID参数是一个查询值(来自查询)。我使用以下方法从ASP.NET2.0调用此报告,它运行良好 window.location.href= strRepServer + strReport + "&rc:Parameters=false&rs:ClearSession=true&plantcd=" + strPlantCD + "&CountID=" + strCountID; 请注意,我们只从ASPX页面

我有一份带有两个参数的
SSRS 2005
报告。CountID参数是一个查询值(
来自查询
)。我使用以下方法从ASP.NET2.0调用此报告,它运行良好

 window.location.href= strRepServer + strReport + "&rc:Parameters=false&rs:ClearSession=true&plantcd=" + strPlantCD + "&CountID=" + strCountID;
请注意,我们只从ASPX页面为参数CountID传递一个字符串值。它仍然可以正常工作

 window.location.href= strRepServer + strReport + "&rc:Parameters=false&rs:ClearSession=true&plantcd=" + strPlantCD + "&CountID=" + strCountID;
现在,我使用以下代码修改代码以使用reportviewercontrol。但是当报告呈现时,它会说“CountID参数缺少一个值”。我提到了以下两篇文章——但都没有用。你知道怎么做吗

  • 注意:我理解,如果我将CountID设置为非查询或设置为文本框,将解决此问题。但是我需要使代码在不更改
    rdl
    文件的情况下工作。[原因是rdl与以前的方法(在没有reportviewer的情况下调用report)配合得很好]

    代码

       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中的参数

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


    是否确保传递的值存在于“计数”数据集中?

    ReportParameter rptParameter=default(ReportParameter); rptparmeter=new ReportParameter(“此处输入参数名称”,“此处输入从数据库获取的列名/值”)


    rptViewer1.LocalReport.SetParameters(rptParameter)

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