我有一个包含 CrystalReportViewer 的普通 asp.Net 页面。我在 Page_Load 方法中使用以下代码来显示报告:
ReportDocument report = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables;
report.Load(Server.MapPath("Reports\\" + Request.Params[0]));
crConnectionInfo.ServerName = ConfigurationManager.AppSettings["ReportSQLServer"];
crConnectionInfo.DatabaseName = ConfigurationManager.AppSettings["ReportSQLDatabase"];
crConnectionInfo.UserID = ConfigurationManager.AppSettings["ReportSQLUsername"];
crConnectionInfo.Password = ConfigurationManager.AppSettings["ReportSQLPassword"];
CrTables = report.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
Session["Report"] = report;
rptViewer.ReportSource = report;
rptViewer.RefreshReport();
但是,无论我加载什么报告,它都会显示如下:
当我在 WinForms 应用程序中使用完全相同的逻辑在其中填充 CrystalReportsViewer 时,报表会按预期显示。
请告知我在 asp.net 网络表单中缺少什么以使报告正确显示。