SSRS与存储过程和参数

时间:2016-08-22 18:57:58

标签: c# sql-server reporting-services reportmanager

我的系统使用基于存储过程的报告。它将参数从C#传递到报告,报告调用存储的proc。我在代码中添加了一个新参数并更改了存储过程和报告,但是当部署时,报表管理器似乎只使用默认值而不使用应用程序传递给它的参数。这是一个已知问题,有没有解决方法?谢谢!

代码:

using System;
using System.Web;
using ICT_Web.App_Code.AcademicTableAdapters;

namespace ICT_Web.reports
{
    public partial class R43FutureStartsReport : System.Web.UI.Page
    {
        ICT_Acd_ProgramsTableAdapter myProgramAdapter = new ICT_Acd_ProgramsTableAdapter();
        string ReportServerUrl = System.Configuration.ConfigurationManager.AppSettings["ICT_WebReportServerURL"];
        Session mySess;

        protected void Page_Load(object sender, EventArgs e)
        {
            mySess = new Session(HttpContext.Current.Session.SessionID);
            if (!IsPostBack)
            {
                lbProgram.DataSource = myProgramAdapter.GetData().Select("campus_id  = " + mySess.campus_id);
                lbProgram.DataTextField = "title";
                lbProgram.DataValueField = "program_id";
                lbProgram.AppendDataBoundItems = true;
                lbProgram.DataBind();
            }
        }
        protected void submit_OnClick(object sender, EventArgs e)
        {
            if (hdnProgramIds.Value != "")
            {
                ReportViewer1.Visible = true;
                ReportViewer1.Reset();
                Microsoft.Reporting.WebForms.ReportParameter[] Param = new Microsoft.Reporting.WebForms.ReportParameter[6];
                Param[0] = new Microsoft.Reporting.WebForms.ReportParameter("campus_id", mySess.campus_id.ToString());
                Param[1] = new Microsoft.Reporting.WebForms.ReportParameter("program_ids", hdnProgramIds.Value);
                Param[2] = new Microsoft.Reporting.WebForms.ReportParameter("user_id", mySess.user_id.ToString());
                if (rball.Checked)
                {
                    Param[3] = new Microsoft.Reporting.WebForms.ReportParameter("I20", "false");
                    Param[4] = new Microsoft.Reporting.WebForms.ReportParameter("NonI20", "false");
                    Param[5] = new Microsoft.Reporting.WebForms.ReportParameter("Both", "true");
                }
                if (rbi20.Checked)
                {
                    Param[3] = new Microsoft.Reporting.WebForms.ReportParameter("I20", "true");
                    Param[4] = new Microsoft.Reporting.WebForms.ReportParameter("NonI20", "false");
                    Param[5] = new Microsoft.Reporting.WebForms.ReportParameter("Both", "false");
                }
                if (rbnoni20.Checked)
                {
                    Param[3] = new Microsoft.Reporting.WebForms.ReportParameter("I20", "false");
                    Param[4] = new Microsoft.Reporting.WebForms.ReportParameter("NonI20", "true");
                    Param[5] = new Microsoft.Reporting.WebForms.ReportParameter("Both", "false");
                }
                ReportViewer1.ServerReport.ReportServerUrl = new System.Uri(ReportServerUrl);
                ReportViewer1.ServerReport.ReportPath = "/General/R-43";
                ReportViewer1.ServerReport.SetParameters(Param);
                ReportViewer1.ShowBackButton = true;
                ReportViewer1.AsyncRendering = true;
                ReportViewer1.SizeToReportContent = true;
            }
        }
    }
}

0 个答案:

没有答案