日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

java水晶报表pull模式_水晶报表pull模式

發(fā)布時(shí)間:2024/9/30 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java水晶报表pull模式_水晶报表pull模式 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

水晶報(bào)表拉模式

最簡單的一種寫法

CrystalReportSource1.ReportDocument.Load(Server.MapPath("Report//*.rpt"));

// SetDatabaseLogon 拉模式中必須用這個(gè)方法來設(shè)置登錄信息,參數(shù)一:用戶名;參數(shù)二:密碼;參數(shù)三:服務(wù)器;參數(shù)四:數(shù)據(jù)庫名

CrystalReportSource1.ReportDocument.SetDatabaseLogon("report", "report", @"*", "database"); ??????? //給水晶報(bào)表傳參數(shù),參數(shù)一:是參數(shù)名,參數(shù)二:參數(shù)值;? ??????? //CrystalReportSource1.ReportDocument.SetParameterValue("Title", "這是一個(gè)測試報(bào)表");

CrystalReportSource1.ReportDocument.SetParameterValue("BeginDate", txtDateBegin.Text.Trim());

//綁定水晶報(bào)表數(shù)據(jù)源。

CrystalReportSource1.DataBind(); // CrystalReportViewer1是水晶報(bào)表瀏覽器,下面是給該瀏覽器賦上對像

CrystalReportViewer1.ReportSource = CrystalReportSource1;

CrystalReportViewer1.DataBind();

這種寫法需填寫登錄數(shù)據(jù)的信息,太麻煩,以下這種可直接登錄并傳遞參數(shù)

public void LoadReport1() ??? {

//定義水晶報(bào)表的數(shù)據(jù)庫連接信息

ConnectionInfo connectionInfo = new ConnectionInfo();

connectionInfo.ServerName = "*";

connectionInfo.DatabaseName = "Database";

connectionInfo.UserID = "report";

connectionInfo.Password = "**";

ReportDocument myReport = new ReportDocument();

string reportPath = Server.MapPath("Report\\*.rpt");

myReport.Load(reportPath);

//將數(shù)據(jù)庫信息傳遞給報(bào)表

SetDBLogonForReport(connectionInfo, myReport);

myReport.SetParameterValue("BeginDate", txtDateBegin.Text.Trim());

myReport.SetParameterValue("EndDate", txtDateFrom.Text.Trim());

//把模板對象賦給報(bào)表前端呈現(xiàn)控件CrystalReportViewer1

CrystalReportViewer1.ReportSource = myReport;

}

private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)

{ ??????? Tables tables = reportDocument.Database.Tables;

foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)

{

TableLogOnInfo tableLogonInfo = table.LogOnInfo;

tableLogonInfo.ConnectionInfo = connectionInfo;

table.ApplyLogOnInfo(tableLogonInfo);

}

}

總結(jié)

以上是生活随笔為你收集整理的java水晶报表pull模式_水晶报表pull模式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。