我在客户的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属于“程序员常用的软件工具”类别,因此按照帮助中心进行主题讨论。 –