【发布时间】:2013-12-10 16:18:14
【问题描述】:
使用 Visual Studio 2010 和 Crystal Reports 13.0。
对于报表,提示用户输入值。然后生成的报告没有问题。
如果用户离开 report.aspx 页面并返回运行另一个报表,则不会显示提示,并且上次运行的报表仍然存在,并带有用户的原始值。
四处寻找解决方案,只找到了两个没有用:
//After the report loads
CrystalReportSource1.ReportDocument.ParameterFields.Clear();
错误:
您不能使用此方法添加、删除或修改参数字段。请直接修改报告。
直接修改报表:
右键单击水晶报表的正文 然后转到:
设计 -> 默认设置.. ->报告
勾选复选框
加载报告时丢弃保存的数据。
这不起作用。之前的报告仍然存在。
所以,我现在想请教一下如何解决这个问题。
一如既往,欢迎提出任何建议。
谢谢
编辑:
这是报告页面的代码。许多报告使用此页面....
CrystalReportSource1.Report.FileName = "reports\\" + fileName + ".rpt";
//CrystalReportSource1.Report.Parameters.Clear();
//CrystalReportSource1.Report = null;
//CrystalReportSource1.Report.Refresh();
if (!string.IsNullOrEmpty(Request.QueryString["item"]))
{
String Item = Request.QueryString["item"];
CrystalDecisions.Web.Parameter temp = new CrystalDecisions.Web.Parameter();
temp.Name = "Item";
temp.DefaultValue = Item;
CrystalReportSource1.Report.Parameters.Add(temp);
}
SqlConnectionStringBuilder settings = new SqlConnectionStringBuilder(MyConnectionString);
_crReportDocument = CrystalReportSource1.ReportDocument;
_crConnectionInfo.ServerName = settings.DataSource;
_crConnectionInfo.DatabaseName = settings.InitialCatalog;
_crConnectionInfo.UserID = settings.UserID;
_crConnectionInfo.Password = settings.Password;
//Get the table information from the report
_crDatabase = _crReportDocument.Database;
_crTables = _crDatabase.Tables;
//Loop through all tables in the report and apply the
//connection information for each table.
for (int i = 0; i < _crTables.Count; i++)
{
_crTable = _crTables[i];
_crTableLogOnInfo = _crTable.LogOnInfo;
_crTableLogOnInfo.ConnectionInfo = _crConnectionInfo;
_crTable.ApplyLogOnInfo(_crTableLogOnInfo);
}
【问题讨论】:
标签: c# asp.net crystal-reports