I am using this code in asp.net to run crystal report :
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();
when I remove this line of code its run always same report automatically :
CrystalReportViewer1.RefreshReport();
when I add this line its ask always for parameters .
How to referesh the report automatically and run the report without asking each time for order and branch id , I confused about it and I need your help please . see image and thank you
try to use this code
repDocument.SetParameterValue("@ORDER_ID", TXTORDERID.Text);
instead of parameter fields this is complete solution and works with me
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;
}