zoukankan      html  css  js  c++  java
  • SSRS_NOTE

    1.Computer -> Manage ->Server and Applications -> Services -> SQL Server Reporting Service(如果启动不了的话 右键属性 logon)


    2.Start->Microsoft SQL Server 2008 R2 ->Configration Tools->Report Services Configration

    aspx:

    <rsweb:ReportViewer ID="rptViewer" ZoomMode="PageWidth" SizeToReportContent="True" runat="server" Height="100%" Width="100%">
    </rsweb:ReportViewer>

    cs:

    1.服务器端

    protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    rptViewer.ShowParameterPrompts = false;
                    rptViewer.ShowPromptAreaButton = false;
                    
                    string reportName = null;
                    Dictionary<string, string> paramList = null;
                    bool hasParam = false;
                    if (this.Request.QueryString["ReportName"] != null)
                        reportName = this.Request.QueryString["ReportName"];
    
                    if (Session["ParamList"] != null)
                        paramList = (Dictionary<string, string>)Session["ParamList"];
                    if (this.Request.QueryString["HasParam"] != null)
                        hasParam = Convert.ToBoolean(this.Request.QueryString["HasParam"]);
    
                    if (reportName != null)
                    {
                        ShowReport(reportName, paramList, hasParam);
                    }
                }
            }
    
            private void ShowReport(string ReportName, Dictionary<string, string> ParamList, bool HasParam)
            {
    
                try
                {
                    rptViewer.Reset();
                    rptViewer.ProcessingMode = ProcessingMode.Remote;
                    string serverUrl = "http://" + ConfigurationManager.AppSettings["ReportServer"].ToString();
                    rptViewer.ServerReport.ReportServerUrl = new Uri(serverUrl);
    
                    if (ReportName == AppConstant.RPT_INVOICEJOURNAL || ReportName == AppConstant.RPT_INVOICE || ReportName == AppConstant.RPT_PAYMENTJOURNAL || ReportName == AppConstant.RPT_PAYMENTREMINDER)
                    {
                        rptViewer.ServerReport.ReportPath = "/Billing/" + ReportName;
                    }
    
                    if (ReportName == AppConstant.RPT_PRINTALLHARBOURGAURDSCHEDULE || ReportName == AppConstant.RPT_HARBOURAGGREMENT || ReportName == AppConstant.RPT_HARBOURAGGREMENTLIST)
                    {
                        rptViewer.ServerReport.ReportPath = "/Harbour/" + ReportName;
                    }
                    //Set report parameter
                    if (ParamList != null && ParamList.Count > 0)
                    {
                        ReportParameterCollection list = new ReportParameterCollection();
                        //every report has parameter SiteID
                        ReportParameter siteId = new ReportParameter();
                        siteId.Name = "SiteID";
                        siteId.Values.Add(CurrentSession.SiteID.ToString());
                        list.Add(siteId);
                        foreach (KeyValuePair<String, String> item in ParamList)
                        {
                            ReportParameter param = new ReportParameter();
                            param.Name = item.Key;
                            param.Values.Add(item.Value);
                            list.Add(param);
                        }
                        this.rptViewer.ServerReport.SetParameters(list);
                    }
    
                    rptViewer.ServerReport.Refresh();
    
                }
                catch (Exception ex)
                {
    
                    WriteSystemLog(AppConstant.EXCEPTION + ex.Message, Convert.ToChar(AppEnum.LogType.E.ToString()));
                }
            }

     2.客户端

    private void ShowReport(string ReportName, Dictionary<string, string> ParamList, bool HasParam)
            {
    
                InvoiceManager objInvocieManager;
                try
                {
                    objInvocieManager = new InvoiceManager();
                    //path for your reports
                    string path = HttpContext.Current.Server.MapPath("~/Invoices/Reports/");
                    rptViewer.Reset();
                    rptViewer.ProcessingMode = ProcessingMode.Local;
                    LocalReport localReport = rptViewer.LocalReport;
                    localReport.ReportPath = path + ReportName + ".rdlc";// rptViewer.LocalReport.ReportPath = "Invoices\\Reports\\PrintInvoiceJournal.rdlc";
                    ReportDataSource rptDataSource;
    
                    //Set report parameter
                    if (HasParam == true)
                    {
                        if (ParamList != null && ParamList.Count > 0)
                        {
                            foreach (KeyValuePair<String, String> item in ParamList)
                            {
                                ReportParameter param = new ReportParameter();
                                param.Name = item.Key;
                                param.Values.Add(item.Value);
                                localReport.SetParameters(param);
                            }
                        }
                    }
    
                    if (ReportName == AppConstant.RPT_PRINTIVOICEJOURNAL)
                    {
                        int invoiceJournalNo = 0;
                        if (ParamList != null && ParamList.Count > 0)
                        {
                            foreach (KeyValuePair<String, String> item in ParamList)
                            {
                                // if (item.Key == "")
                                invoiceJournalNo = Convert.ToInt16(item.Value);
                            }
                        }
    
                        //Bind report data source
                        rptDataSource = new ReportDataSource();
                        rptDataSource.Name = "dsPrintInvoiceJournal";
                        rptDataSource.Value = objInvocieManager.PrintInvoiceJournal(CurrentSession.SiteID, invoiceJournalNo);
                        localReport.DataSources.Add(rptDataSource);
    
                    } 
                    
    
                    localReport.Refresh();
    
                }
                catch (Exception ex)
                {
    
                    WriteSystemLog(AppConstant.EXCEPTION + ex.Message, Convert.ToChar(AppEnum.LogType.E.ToString()));
                }
                finally
                {
                    objInvocieManager = null;
                }
            }

     sample reports of reporting services  http://msftrsprodsamples.codeplex.com/

  • 相关阅读:
    游戏服务器架构概要
    牛客网_Go语言相关练习_选择题(3)
    Go语言实践_实现一(服务器端)对多(客户端)在线聊天室
    Go语言实践_实现一(客户端)对一(服务器端)聊天室
    牛客网_Go语言相关练习_选择题(2)
    飞鱼48小时游戏创作嘉年华_厦门Pitch Time总结与收获
    牛客网_Go语言相关练习_选择题(1)
    Go语言_iota用法
    游戏服务器概述
    LeetCode_1. Two Sum_Solution
  • 原文地址:https://www.cnblogs.com/cw_volcano/p/3096871.html
Copyright © 2011-2022 走看看