【问题标题】:Unable to pass parameters to SSRS report in ASP.NET page无法将参数传递给 ASP.NET 页面中的 SSRS 报告
【发布时间】:2013-05-28 10:59:42
【问题描述】:

您好,我在向部署在 ASP.NET 页面中的服务器上的 SSRS 报告提供参数时出错。

请参考下面的代码,让我知道问题出在哪里?

ReportExecutionService rs = new ReportExecutionService();
        string rptURL = System.Configuration.ConfigurationManager.AppSettings["rptURL"].ToString();
        string rptPath = System.Configuration.ConfigurationManager.AppSettings["Page1SLScorecardReortForDownload"].ToString();
        //Microsoft.Reporting.WebForms.ReportParameter[] paramlist = new Microsoft.Reporting.WebForms.ReportParameter[3];
        //paramlist[0] = new Microsoft.Reporting.WebForms.ReportParameter("Week", "2013-05-03");
        //paramlist[1] = new Microsoft.Reporting.WebForms.ReportParameter("year", "Fiscal Calendar 2013");
        //paramlist[2] = new Microsoft.Reporting.WebForms.ReportParameter("Month", "Fiscal May, 2013");
        ParameterValue[] paramlist = new ParameterValue[3];
        //Microsoft.Reporting.WebForms.ReportParameter[] paramlist = new Microsoft.Reporting.WebForms.ReportParameter[3];
        paramlist[0] = new ParameterValue();
        paramlist[0].Name = "Week";
        paramlist[0].Value = "2013-05-03";
        paramlist[1] = new ParameterValue();
        paramlist[1].Name = "year";
        paramlist[1].Value = "Fiscal Calendar 2013";
        paramlist[2] = new ParameterValue();
        paramlist[2].Name = "Month";
        paramlist[2].Value = "Fiscal May, 2013";

       //ReportViewer1.ServerReport.SetParameters(paramlist);

        rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
        rs.Url = rptURL;
        byte[] result = null;
        string reportPath = rptPath;
        string format = "EXCEL";
        string historyID = null;
        string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";

        string encoding;
        string mimeType;
        string extension;
        ReportingWS.Warning[] warnings = null;
        string[] streamIDs = null;
        ReportingWS.ExecutionInfo execInfo = new ReportingWS.ExecutionInfo();

        ReportingWS.ExecutionHeader execHeader = new ReportingWS.ExecutionHeader();
        rs.ExecutionHeaderValue = execHeader;

        execInfo = rs.LoadReport(reportPath, historyID);
        rs.SetExecutionParameters(paramlist, "en-us");
        String SessionId = rs.ExecutionHeaderValue.ExecutionID;

        try
        {
            result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
            execInfo = rs.GetExecutionInfo();
        }
        catch (Exception ex)
        {
            //AlnErrorHandler.HandleError(ex);
        }

【问题讨论】:

    标签: asp.net reporting-services parameters


    【解决方案1】:
                parameters.Add(new ReportParameter("FyId", Convert.ToInt16(objSession.FyId).ToString()));
                parameters.Add(new ReportParameter("AccountGroupId", cmbAccountGroup.SelectedValue));
                parameters.Add(new ReportParameter("LedgerId", cmbLedgerId.SelectedValue));              
                rptvwMain.ServerReport.SetParameters(parameters);
    

    像这样传递参数......

    【讨论】:

    • 不工作。它说构造函数不接受两个值。我想强调一下,我并没有尝试将参数传递给报表查看器,因为我在另一个报表中做了类似的事情,并且参数很容易传递给报表查看器。我想得到报告的结果,稍后在这里写入一个文件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多