SSRS with stored procedure and parameter

163 views Asked by At

My system uses reports based on stored procedures. It passes parameters from C# to the report and the report calls the stored proc. I added a new parameter to the code and changed the stored proc and report, but when deployed report manager seems to use only the defaults and not use the parameters being passed to it by the app. Is this a known issue and is there any workaround? Thanks!

Code:

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

There are 0 answers