首次运行时,报告加载时间过长

时间:2017-06-21 08:47:30

标签: c# crystal-reports

当我调试我的项目并查看我的报告时,加载需要太多时间 - 至少一两分钟。当我重新加载相同的报告并再次运行它时,它可以正常工作,没有加载时间。如何减少加载时间?

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++;

    }

}

1 个答案:

答案 0 :(得分:0)

(这是在黑暗中拍摄,我会写评论但我不允许。)

您是否尝试在报告中取消设置打印机?在“页面设置”对话框中选中“无打印机(优化屏幕显示)”。

我曾经遇到过寻找(网络)打印机的报告问题,导致启动/加载时间很长。