0
当我调试我的项目并查看我的报告时,加载时间太长 - 至少一两分钟。当我重新加载相同的报告并再次运行它时,它可以在没有加载时间的情况下正常运行。我怎样才能缩短加载时间?第一次运行时报告花费的时间过长
ReportDocument reportDocument = new ReportDocument();
TableLogOnInfos tableLogOnInfos = new TableLogOnInfos();
TableLogOnInfo tableLogOnInfo = new TableLogOnInfo();
ConnectionInfo connectionInfo = new ConnectionInfo();
try
{
string startupPath = Application.StartupPath;
string filename;
filename = startupPath + "\\Report\\" + rptSettings;
reportDocument.Load(filename);
}
catch (Exception ex)
{
KryptonMessageBox.Show(ex.Message, "Error Occured", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
}
connectionInfo.ServerName = Program.serverName;
connectionInfo.DatabaseName = Program.dbName;
connectionInfo.UserID = Program.saName;
connectionInfo.Password = Program.pw;
Tables tables = reportDocument.Database.Tables;
foreach (Table table in tables)
{
tableLogOnInfo = table.LogOnInfo;
tableLogOnInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogOnInfo);
}
string month = "";
month = BillingMonth + " " + DateTime.Now.Year;
reportDocument.SetParameterValue("dueDate", paraDue);
reportDocument.SetParameterValue("feeMonth", BillingMonth);
reportDocument.SetParameterValue("tuitionFee", TutionFee);
reportDocument.SetParameterValue("TotalFee", Total);
reportDocument.SetParameterValue("issueDate", Total);
reportDocument.SetParameterValue("class", Total);
reportDocument.SetParameterValue("fatherName", Total);
reportDocument.SetParameterValue("studentName", Total);
reportDocument.SetParameterValue("annualCharges", Total);
reportDocument.SetParameterValue("validTill", Total);
reportDocument.SetParameterValue("ArrearsFee", Total);
reportDocument.SetParameterValue("JunJulFee", Total);
reportDocument.SetParameterValue("Fine", Total);
reportDocument.SetParameterValue("Discount", Total);
//reportDocument.RecordSelectionFormula = "{tblRegistration.id}=" + ID;
try
{
if (!printAll)
{
crystalReportViewer1.ReportSource = reportDocument;
}
else
{
reportDocument.PrintToPrinter(1, true, 1, 1);
sNo++;
}
}