以下為aspx.cs程式,page load的時候傳入ProductID給CrystalReport
當然在CrystalReport.rpt裡面要設定"參數欄位"
然後在"資料錄選擇"加入條件式
如:{Risk.ProjectID} = {?ProjectID}

aspx.cs程式:     
            //load crystal report
            this.CrystalReportSource1.Report.FileName = Server.MapPath("RiskCrystalReport.rpt");
            //設定資料庫連線訊息
            TableLogOnInfo dbConn = new TableLogOnInfo();
            dbConn.ConnectionInfo.DatabaseName = "DB";
            dbConn.ConnectionInfo.ServerName = "XX.XX.XX.XX";
            dbConn.ConnectionInfo.UserID = "User";
            dbConn.ConnectionInfo.Password = "Password";
            this.CrystalReportSource1.ReportDocument.Database.Tables[0].ApplyLogOnInfo(dbConn);

            //load param
            CrystalDecisions.Web.Parameter param = new CrystalDecisions.Web.Parameter();
            param.Name = "ProductID";
            param.DefaultValue = "1";

            //add param
            this.CrystalReportSource1.Report.Parameters.Add(param);
 
            //bind
            this.CrystalReportViewer1.ReportSourceID = this.CrystalReportSource1.ID;
            this.CrystalReportViewer1.DataBind();
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 JohnDX 的頭像
    JohnDX

    我要回家想一想~

    JohnDX 發表在 痞客邦 留言(0) 人氣()