locked
Code for launching a report RRS feed

  • Question

  • User-1756429883 posted

    Good day all, not sure under which thread to post my question since it can be apply to 3 . Anyway my question is simple, and I do feel like a newbie asking it , which I am :-).

    I just finish my report, using reporting services. Now I just want the user to click on a button, and when he clicks on it, I want the report to open. I have never done this so I don't have a clue as to what is the code in order for the report to launch when they click the button.

     

    Thank you for your time,

    Tuesday, January 31, 2012 11:04 AM

Answers

  • User-8475372 posted

    Hey Gindy,

    This surely is an interesting aspect of .net and reporting services. Once the reports are deployed onto any server. You can use a reportviewer control to view them over your web pages. However, there are couple of ways to do this, with using the parameters of the reporting server itself, or by using custom paramters. Below is the simple code, which will allow you to start off with this..

    Any more issues shud you run into, please feel free to post it here. 

    Microsoft.Reporting.WebForms.ReportParameter[] RptParameters;
     
                reportViewer.ServerReport.ReportServerUrl = new System.Uri(ConfigurationManager.AppSettings["ReportServerURL"]);
                reportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
                reportViewer.ToolBarItemBorderColor = System.Drawing.Color.PowderBlue;
                reportViewer.ToolBarItemBorderStyle = BorderStyle.Double;
     
                string strUserName = ConfigurationManager.AppSettings["UserName"].ToString();
                string strPassword = ConfigurationManager.AppSettings["Password"].ToString();
                string strDomain = ConfigurationManager.AppSettings["Domain"].ToString();
                reportViewer.ServerReport.ReportServerCredentials = new ReportCredentials(strUserName, strPassword, strDomain);
                string strReport = string.Empty;
                strReport = ConfigurationManager.AppSettings["ReportsFolder"] + Request.QueryString["ReportName"].ToString();
    
    Below snippet shows on how to pass parameters to the report  :
    
                    this.reportViewer.ServerReport.ReportPath = strReport;
                    RptParameters = new Microsoft.Reporting.WebForms.ReportParameter[1];
                    RptParameters[0] = new Microsoft.Reporting.WebForms.ReportParameter("                                                      <ParameterName>", "<ParameterValue>");               
                    this.reportViewer.ServerReport.SetParameters(RptParameters);     
                    reportViewer.ServerReport.Refresh();
    
    You can pass any number of parameters to the report. Just make sure that the <ParameterName> matches with the parameter name in the report. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 31, 2012 12:18 PM

All replies

  • User-8475372 posted

    Hey Gindy,

    This surely is an interesting aspect of .net and reporting services. Once the reports are deployed onto any server. You can use a reportviewer control to view them over your web pages. However, there are couple of ways to do this, with using the parameters of the reporting server itself, or by using custom paramters. Below is the simple code, which will allow you to start off with this..

    Any more issues shud you run into, please feel free to post it here. 

    Microsoft.Reporting.WebForms.ReportParameter[] RptParameters;
     
                reportViewer.ServerReport.ReportServerUrl = new System.Uri(ConfigurationManager.AppSettings["ReportServerURL"]);
                reportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
                reportViewer.ToolBarItemBorderColor = System.Drawing.Color.PowderBlue;
                reportViewer.ToolBarItemBorderStyle = BorderStyle.Double;
     
                string strUserName = ConfigurationManager.AppSettings["UserName"].ToString();
                string strPassword = ConfigurationManager.AppSettings["Password"].ToString();
                string strDomain = ConfigurationManager.AppSettings["Domain"].ToString();
                reportViewer.ServerReport.ReportServerCredentials = new ReportCredentials(strUserName, strPassword, strDomain);
                string strReport = string.Empty;
                strReport = ConfigurationManager.AppSettings["ReportsFolder"] + Request.QueryString["ReportName"].ToString();
    
    Below snippet shows on how to pass parameters to the report  :
    
                    this.reportViewer.ServerReport.ReportPath = strReport;
                    RptParameters = new Microsoft.Reporting.WebForms.ReportParameter[1];
                    RptParameters[0] = new Microsoft.Reporting.WebForms.ReportParameter("                                                      <ParameterName>", "<ParameterValue>");               
                    this.reportViewer.ServerReport.SetParameters(RptParameters);     
                    reportViewer.ServerReport.Refresh();
    
    You can pass any number of parameters to the report. Just make sure that the <ParameterName> matches with the parameter name in the report. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 31, 2012 12:18 PM
  • User-1188422920 posted

    Sir

    new to SSRS

    may i know the benefits of using  SQL Server Reporting Services we can do this by simply retreving data by sql select statement into dataset then in gridview.

    Thursday, February 2, 2012 7:17 AM