我在我的应用程序中有 sap Crystal Report 13,它在简单的表中运行良好,但在特定情况下,例如:我有一个表,当我加载此表时通过存储过程加载,然后将调用报告并在显示报告后我使用删除查询清理表。如果我评论该查询报告显示记录,否则会出现空报告。请看我的代码:
private void btnPreview_Click(System.Object sender, System.EventArgs e)
{
if (IsErrorFound() == false)
{
MyResources.WaitDialogCreate("Loading....");
string FormulaString = "";
string Parameters = "";
//***** Insert Data in table naamed tblReportTrialBalanceWith (With and Without Of Opening Bal) FROM Store Procedure
string Qry = "INSERT INTO tblReportTrialBalanceWithOpening EXEC [spTrialBalance] @MinFY = '" + GlobalVriables.FYearDateStart.Year.ToString() + "'," +
"@MaxFY = '" + GlobalVriables.FYearDateEnd.Year.ToString() + "'," +
"@DateFrom = '" + MyResources.getDateForDB(dteFromDate.Text.Trim()) + "'," +
"@DateTo = '" + MyResources.getDateForDB(dteToDate.Text.Trim()) + "'," +
"@FromCode = '" + lkpFromCode.Text.Trim() + "'," +
"@ToCode = '" + lkpToCode.Text.Trim() + "'," +
"@Category = '" + rdoAccCategory.Text.Trim() + "'";
DatabaseHelper.ExecuteNonQuery(Qry);
if (chkWithOutOB.Checked == true)
{
//************* Parameters
Parameters = "CompanyName=" + GlobalVriables.CompanyName +
"&StartingDate=" + dteFromDate.Text +
"&EndingDate=" + dteToDate.Text +
"&Category=" + (rdoAccCategory.SelectedIndex == 0 ? "All Categories" : rdoAccCategory.Text.Trim()) +
"&FYear=[" + GlobalVriables.FYearDateStart.Year + "-" + GlobalVriables.FYearDateEnd.Year + "]";
switch (rdoAccCategory.SelectedIndex)
{
case 0:
Parameters = Parameters + "&ReportCase=0";
break;
case 2:
Parameters = Parameters + "&ReportCase=2";
break;
default:
Parameters = Parameters + "&ReportCase=1";
break;
}
MyResources.ViewReport("RptTrialBalanceWithOutOB.rpt", FormulaString, Parameters);
////***** Clean up tblReportTrialBalanceWithOpening for Future use.
//Qry = "DELETE FROM tblReportTrialBalanceWithOpening";
//DatabaseHelper.ExecuteNonQuery(Qry);
}
else
{
//************* Parameters
Parameters = "CompanyName=" + GlobalVriables.CompanyName +
"&StartingDate=" + dteFromDate.Text.Trim() +
"&EndingDate=" + dteToDate.Text +
"&Category=" + (rdoAccCategory.SelectedIndex == 0 ? "All Categories" : rdoAccCategory.EditValue.ToString()) +
"&FYear=[" + GlobalVriables.FYearDateStart.Year + "-" + GlobalVriables.FYearDateEnd.Year + "]";
switch (rdoAccCategory.SelectedIndex)
{
case 0:
Parameters = Parameters + "&ReportCase=0";
break;
case 2:
Parameters = Parameters + "&ReportCase=2";
break;
default:
Parameters = Parameters + "&ReportCase=1";
break;
}
MyResources.ViewReport("RptTrialBalance.rpt", FormulaString, Parameters);
////***** Clean up tblReportTrialBalanceWithOpening for Future use.
//Qry = "DELETE FROM tblReportTrialBalanceWithOpening";
//DatabaseHelper.ExecuteNonQuery(Qry);
}
MyResources.WaitDialogDispose();
//***** Clean up tblReportTrialBalanceWithOpening for Future use.
Qry = "DELETE FROM tblReportTrialBalanceWithOpening";
DatabaseHelper.ExecuteNonQuery(Qry);
}
}
如果我评论它,你可以看到我的删除查询。我的报告显示记录。在我的情况下,删除查询是必须的。所以请帮助我,我完全分散了。还有一件事记得我的应用程序从 2010 年升级到 2012 年,视觉工作室成功地预料到了这个问题。