在搜索到的 Microsoft Visual Studio 2005中使用水晶报表,使用其中的web
【WEB方式下】
///功能:拉模式提取水晶报表
// SetDatabaseLogon 拉模式中必须用这个方法来设置登录信息,参数一:用户名;参数二:密码;参数三:服务器;参数四:数据库名
CrystalReportSource1.ReportDocument.SetDatabaseLogon("sa", "123456", @"SYWZSWL\SQLEXPRESS", "Test");
////在开发完成后,部署到服务器上,如果数据库名改变,报表会提示 需要更多信息。英文版:The report you requested requires further information
改为:
// SetDatabaseLogon 拉模式中必须用这个方法来设置登录信息,参数一:用户名;参数二:密码;参数三:服务器;参数四:数据库名
//CrystalReportSource1.ReportDocument.SetDatabaseLogon(ConfigurationSettings.AppSettings["ConnectionUserId"].ToString(), ConfigurationSettings.AppSettings["ConnectionPwd"].ToString(), ConfigurationSettings.AppSettings["ConnectionServer"].ToString(), ConfigurationSettings.AppSettings["ConnectionDatabase"].ToString());
TableLogOnInfo logonInfo = new TableLogOnInfo();
ConnectionInfo conn = new ConnectionInfo();
conn.ServerName = ConfigurationSettings.AppSettings["ConnectionServer"].ToString();
conn.DatabaseName = ConfigurationSettings.AppSettings["ConnectionDatabase"].ToString();
conn.UserID = ConfigurationSettings.AppSettings["ConnectionUserId"].ToString();
conn.Password = ConfigurationSettings.AppSettings["ConnectionPwd"].ToString();
foreach (CrystalDecisions.CrystalReports.Engine.Table table in CrystalReportSource1.ReportDocument.Database.Tables)
{
logonInfo = table.LogOnInfo;
logonInfo.ConnectionInfo = conn;
table.ApplyLogOnInfo(logonInfo);
table.Location = table.Name;
}