2017-06-21 88 views
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++; 

    } 

} 

回答

0

(這是一個在黑暗中拍攝,我會一直寫了評論,但我不允許。)

您是否嘗試過取消設置在報表中的打印機嗎?在「頁面設置」對話框中選中「無打印機(優化屏幕顯示)」。

我曾經遇到過尋找(網絡)打印機的問題,導致啓動/加載時間很長。