为什么crystal报表没有自动刷新参数?
Why crystal report not refresh the parameters automatically?
我在 asp.net 中使用此代码到 运行 crystal 报告:
paramField.Name = "@ORDER_ID";
paramDiscreteValue.Value = TXTORDERID.Text.ToString();
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
paramField = new ParameterField(); // <-- This line is added
paramDiscreteValue = new ParameterDiscreteValue(); // <-- This line is added
paramField.Name = "@branch_id";
paramDiscreteValue1.Value = TXTDEPTID.Text.ToString();
paramField.CurrentValues.Add(paramDiscreteValue1);
paramFields.Add(paramField);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
CrystalReportViewer1.ReuseParameterValuesOnRefresh = false;
CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
reportDocument.Load(Server.MapPath("~/RPT/RPTCCOVIDRESULTS.rpt"));
CrystalReportViewer1.ReportSource = reportDocument;
CrystalReportViewer1.RefreshReport();
当我删除这行代码时,它 运行 总是自动生成相同的报告:
CrystalReportViewer1.RefreshReport();
当我添加这一行时,它总是询问参数。
如何自动引用报告和 运行 报告而无需每次都询问订单和分支 ID,我对此感到困惑,我需要你的帮助。
看图谢谢
尝试使用此代码
repDocument.SetParameterValue("@ORDER_ID", TXTORDERID.Text);
而不是参数字段,这是完整的解决方案并且适用于我
var connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = "server_name";
connectionInfo.DatabaseName = "database_name";
connectionInfo.Password = "password";
connectionInfo.UserID = "user_name";
connectionInfo.Type = ConnectionInfoType.SQL;
connectionInfo.IntegratedSecurity = false;
ReportDocument repDocument = new ReportDocument();
repDocument.Load(Server.MapPath("~/report.rpt"));
repDocument.SetParameterValue("@ORDER_ID", TXTORDERID.Text);
repDocument.SetParameterValue("@branch_id", TXTBRANCHID.Text);
repDocument.SetDatabaseLogon("user_name", "password");
CrystalReportViewer1.ReportSource = repDocument;
CrystalReportViewer1.DataBind();
for (int i = 0; i < CrystalReportViewer1.LogOnInfo.Count; i++)
{
CrystalReportViewer1.LogOnInfo[i].ConnectionInfo = connectionInfo;
}
我在 asp.net 中使用此代码到 运行 crystal 报告:
paramField.Name = "@ORDER_ID";
paramDiscreteValue.Value = TXTORDERID.Text.ToString();
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
paramField = new ParameterField(); // <-- This line is added
paramDiscreteValue = new ParameterDiscreteValue(); // <-- This line is added
paramField.Name = "@branch_id";
paramDiscreteValue1.Value = TXTDEPTID.Text.ToString();
paramField.CurrentValues.Add(paramDiscreteValue1);
paramFields.Add(paramField);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
CrystalReportViewer1.ReuseParameterValuesOnRefresh = false;
CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
reportDocument.Load(Server.MapPath("~/RPT/RPTCCOVIDRESULTS.rpt"));
CrystalReportViewer1.ReportSource = reportDocument;
CrystalReportViewer1.RefreshReport();
当我删除这行代码时,它 运行 总是自动生成相同的报告:
CrystalReportViewer1.RefreshReport();
当我添加这一行时,它总是询问参数。
如何自动引用报告和 运行 报告而无需每次都询问订单和分支 ID,我对此感到困惑,我需要你的帮助。 看图谢谢
尝试使用此代码
repDocument.SetParameterValue("@ORDER_ID", TXTORDERID.Text);
而不是参数字段,这是完整的解决方案并且适用于我
var connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = "server_name";
connectionInfo.DatabaseName = "database_name";
connectionInfo.Password = "password";
connectionInfo.UserID = "user_name";
connectionInfo.Type = ConnectionInfoType.SQL;
connectionInfo.IntegratedSecurity = false;
ReportDocument repDocument = new ReportDocument();
repDocument.Load(Server.MapPath("~/report.rpt"));
repDocument.SetParameterValue("@ORDER_ID", TXTORDERID.Text);
repDocument.SetParameterValue("@branch_id", TXTBRANCHID.Text);
repDocument.SetDatabaseLogon("user_name", "password");
CrystalReportViewer1.ReportSource = repDocument;
CrystalReportViewer1.DataBind();
for (int i = 0; i < CrystalReportViewer1.LogOnInfo.Count; i++)
{
CrystalReportViewer1.LogOnInfo[i].ConnectionInfo = connectionInfo;
}