读者朋友:
您好,把数据库连接信息写在INI文件中,然后动态链接,可以参考下面代码:
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = ConfigurationManager.AppSettings["ServerName"];
connectionInfo.DatabaseName =
ConfigurationManager.AppSettings["DatabaseName
connectionInfo.UserID = ConfigurationManager.AppSettings["UserID"];
connectionInfo.Password =
ConfigurationManager.AppSettings["Password"];
Tables tables = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table
table in tables)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
}