我在客戶的PC上使用Crystal Reports Runtime 13.0.5在我的WinForms應用程序中打印帳單。一切都很順利,直到我的一些客戶開始面臨問題。如何在Crystal Report運行時中刪除「加載報告失敗」錯誤?
經過一整天的報告生成/打印,在晚上,每當我生成報告時,水晶報告開始給出錯誤「加載報告失敗」。
我發現我的客戶在一天內生成了數百個報告,而CR運行時每次生成帳單時都會在臨時文件夾中生成臨時文件。也許這些數百個全天臨時文件會給CR運行時帶來負擔,並導致它在晚上給出這個錯誤。
關閉應用程序並從該文件夾中刪除所有臨時文件允許CR運行時再次開始工作。我還在註冊表中將Crystal Reports的最大作業限制從75增加到了1000。
但是,我不能告訴我的所有客戶關閉應用程序,刪除所有的臨時文件,然後再次使用該應用程序。我需要永久解決這個問題。
或者,如果沒有任何永久性解決方案,是否有辦法在每次生成報告後刪除臨時文件?
編輯: 我試圖處置報告,但沒有成功。我在報表查看器窗體上顯示主窗體和設置數據源的報表對話框。如果在顯示報告查看器窗口之前處理我的報告,則會出現錯誤「未將對象引用設置爲對象的實例」。附加代碼以便更好地理解。
在主要形式有:
if (str1 == "A4Printer")
{
Frm_ReportViewer _objfrm_ReportViewer = new Frm_ReportViewer();
DataTable dtDetailsReport = _objCommon.DataGridView2DataTable(dgv_SaleForm, "table");
SendData _obj = new SendData(_objfrm_ReportViewer.ReceiveSalesDataA4);
_obj(dtDetailsReport, txt_BillNo.Text, accno, txt_PaidAmount.Text, txt_Balence.Text, txt_TotalAmount.Text, txtdisc.Text);
_objfrm_ReportViewer.ShowDialog();
ClearSale();
MasterClear();
cmb_CustomerName.Select();
}
在報告查看器形式:
public void ReceiveSalesDataA4(DataTable dtDetail, string BillNO, string AccNo, string PaidAmount, string Balance, string TotalAmount, string Disc)
{
CrystalReport.Crt_SaleBill _objReport = new CrystalReport.Crt_SaleBill();
string CompanyMaster = "SELECT tbl_CompanyMaster.CompanyName, tbl_CompanyMaster.Addressline1, tbl_CompanyMaster.Addressline2, tbl_CompanyMaster.MobileNo1, tbl_CompanyMaster.MobileNo2, tbl_CompanyMaster.Landlineno, tbl_CompanyMaster.VatNo, tbl_CompanyMaster.Tinno FROM tbl_CompanyMaster";
string CustomerMaster = "SELECT CustomerName,AccNo,Address,PhoneNo,Dat FROM tbl_CustomerMaster WHERE (AccNo = '" + AccNo + "')";
DataTable dt_CustomerMaster = _objSQLHelper.GetDataTable(CustomerMaster);
_objReport.Database.Tables["dt_registration"].SetDataSource(dt_registration);
_objReport.Database.Tables["dt_SalesThermalReport"].SetDataSource(dtDetail);
_objReport.Database.Tables["dt_CustomerMaster"].SetDataSource(dt_CustomerMaster);
_objReport.SetParameterValue("BillNo", BillNO);
_objReport.SetParameterValue("PaidAmount", PaidAmount);
_objReport.SetParameterValue("Disc", Disc);
_objReport.SetParameterValue("Balance", Balance);
_objReport.SetParameterValue("TotalAmount", TotalAmount);
_objReport.SetParameterValue("cdt", clsVariable.CDate);
Crt_ReportViewer.ReportSource = _objReport;
}
如果我把_objReport.Dispose();
以上Crt_ReportViewer.ReportSource = _objReport;
後, 主要形式_objfrm_ReportViewer.ShowDialog();
上給出了錯誤「未將對象引用設置爲對象的實例「。所以,我不能在這裏處理它。我正在尋找另一種解決方案。對於任何錯誤我都很抱歉,我是Crystal Report的新手,這個問題對於我的公司來說太重要了,因爲客戶端因爲「加載報告失敗」錯誤而感到惱火。先謝謝你。
**主持人對潛在的近距離投票人的提示:** Crystal Reports屬於「程序員常用的軟件工具」類別,因此按照幫助中心進行主題討論。 –