C#, Crystal Reports parameter dialog displays randomly

Hi,

I assign Crystal Reports parameter values and the report displays great with no dialog popups, but sometimes the dialog just appears for no reason and I cannot figure out why.
I run a report and it works great, I keep the same parameter values and sometimes change them, but the dialog still only appears randomly.

Please see my code below. This code is only code that is relevant to handling my parameters. I removed any other unnecessary code.

Thanks
public partial class frm_ReportViewer : Form
    {
        CrystalDecisions.CrystalReports.Engine.ReportDocument myReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        private const string PARAMETER_REPORT_HEADER = "ReportHeader";

	private void frm_ReportViewer_Load(object sender, EventArgs e)
        {            
        	string reportPath = "";
        	ArrayList arrayListreportheader = new ArrayList();
		reportPath = Application.StartupPath + "\\" + "creport.rpt";
                myReport.Load(reportPath);
                arrayListreportheader.Add("Header text here");

                //SQL query and fill dataset here

                myReport.SetDataSource(mydataset);
		
		crystalReportViewer1.ReportSource = myReport;
                    
	        ParameterFields parameterFields = myReport.ParameterFields;
       		SetReportHeaderParameterField(parameterFields, arrayListreportheader);
	        
         
        }

private void SetReportHeaderParameterField(ParameterFields parameterFields, ArrayList arrayList)
        {            
            ParameterField parameterField = parameterFields[PARAMETER_REPORT_HEADER];
            ParameterValues currentParameterValues = new ParameterValues();

            foreach (object submittedValue in arrayList)
            {
                ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
                parameterDiscreteValue.Value = submittedValue.ToString();
                currentParameterValues.Add(parameterDiscreteValue);
            }

            parameterField.CurrentValues = currentParameterValues;
        }
}

Open in new window

DeonMAsked:
Who is Participating?
 
DeonMConnect With a Mentor Author Commented:
That produces the dialog popup every time then.
I moved Line:19 to Line: 23 and thus far i haven't received the dialog once.
Will need to test more though to confirm if this indeed has fixed the problem. This change makes more sense as well, but I know I wrote this sequence for a reason awhile back.
0
 
Death259Commented:
What if for the last line in your frm_ReportViewer_Load you refresh the crystal report?
0
 
Death259Commented:
That was going to be my next suggestion. I've always run into crystal report parameter problems like the one you are experiencing, and i usually solve it with a refresh somewhere, or mvoing where i change the report source.
0
 
mlmccCommented:
If you refresh, Crystal will drop the assigned parameter values and prompt for new values.

DO all parameters get legal values?

I think your idea of moving the reportsource assignment is the answer.

mlmcc
0
All Courses

From novice to tech pro — start learning today.