日期:2014-05-18 浏览次数:20412 次
public class LoginCrystalReport { public void Login(CrystalDecisions.CrystalReports.Engine.ReportDocument report) { string servername, username, password; // t Database Logon to main report servername = System.Configuration.ConfigurationSettings.AppSettings["servername"]; username = System.Configuration.ConfigurationSettings.AppSettings["userid"]; password = System.Configuration.ConfigurationSettings.AppSettings["pass"]; foreach (CrystalDecisions.Shared.IConnectionInfo connection in report.DataSourceConnections) { if (connection.ServerName == servername) { connection.SetLogon(username, password); } } // t Database Logon to subreport foreach (CrystalDecisions.CrystalReports.Engine.ReportDocument subreport in report.Subreports) { foreach (CrystalDecisions.Shared.IConnectionInfo connection in subreport.DataSourceConnections) { if (connection.ServerName == servername) { connection.SetLogon(username, password); } } } } }