日期:2014-05-18 浏览次数:20474 次
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); } } } } }
------解决方案--------------------
http://www.cnblogs.com/lodestar/archive/2007/09/27/907827.html