日期:2014-05-20 浏览次数:21041 次
public class TLReportDocument:ReportDocument { //报表属性 public string ch_ReportName; public string en_ReportName; public string ReportPath; public string ExportPath; public bool exportIfModify; //报表与数据库的连接 public string ReportServerName; public string ReportDataBaseName; public string UserID; public string Password; public TLReportDocument() { } //加载报表 public ReportDocument Load() { this.Load(this.ReportPath + this.en_ReportName); return this; } //连接数据库 public void LoginDataBase() { Database crDatabase; CrystalDecisions.CrystalReports.Engine.Tables crTables; TableLogOnInfo crTableLogOnInfo; ConnectionInfo crConnectionInfo; crConnectionInfo = new ConnectionInfo(); crConnectionInfo.ServerName = this.ReportServerName; crConnectionInfo.DatabaseName = this.ReportDataBaseName; crConnectionInfo.UserID = this.UserID; crConnectionInfo.Password = this.Password; //取得报表连接的表数 crDatabase = this.Database; crTables = crDatabase.Tables; //设置报表每z张表的连接 foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables) { crTableLogOnInfo = crTable.LogOnInfo; crTableLogOnInfo.ConnectionInfo = crConnectionInfo; crTable.ApplyLogOnInfo(crTableLogOnInfo); } } }