Question

This was working correctly in Visual Studio 2008, but since I have switch to Visual Studio 2010 and Crystal Reports for Visual Studio 2010, my passed parameters are ignored.

They display in the report, just ignored when it comes to the selection formula! Here is my code for creating the report and passing the parameters.

 private void Prepare()
    {
        var reportDocument = new ReportDocument();

        string reportPath = string.Format(
            "{0}\\{1}",
            Globals.FormPath,
            this.FormTemplate.Filename);

        reportDocument.Load(reportPath);

        ParameterDiscreteValue parameter;

        foreach (var control in this.FormTemplateFieldControls)
        {
            switch (control.FormTemplateField.DataType)
            {
                case FormFieldDataType.Date:
                    this.AddParameterForDateTime(
                        reportDocument,
                        control.FormTemplateField.Name,
                        (DateTime)control.EditValue);
                    break;
                case FormFieldDataType.DateTime:
                    this.AddParameterForDateTime(
                        reportDocument,
                        control.FormTemplateField.Name,
                        (DateTime)control.EditValue);
                    break;
                case FormFieldDataType.Time:
                    this.AddParameterForDateTime(
                        reportDocument,
                        control.FormTemplateField.Name,
                        (DateTime)control.EditValue);
                    break;
                case FormFieldDataType.Guid:
                    this.AddParameterForGuid(
                        reportDocument,
                        control.FormTemplateField.Name,
                        (Guid)control.EditValue);
                    break;
                default:
                    this.AddParameterForString(
                        reportDocument,
                        control.FormTemplateField.Name,
                        control.EditValue.ToString());
                    break;
            }
        }

        this.SetConnectionInfo(reportDocument);

        var frm = new FormViewer();

        frm.Report = reportDocument;

        frm.ShowDialog();

        frm.Dispose();

        this.Close();
    }

When I run the report from the designer it works just fine. You can see the parameters are being passed as I am displaying them in my report.

alt text

For my reports that run from stored procedures the parameters seem to pass just fine, it's just the ones composed of all tables.

For what it's worth, here is my selection formula:

 {employee.HireDate} >= {?StartDate} And {employee.HireDate} <= {?EndDate}
Was it helpful?

Solution

This has been resolved with the latest version of Crystal Reports for Visual Studio 2010.

OTHER TIPS

When you say "they don't get passed", what DOES get passed? Are they blank?

You might review the parameters themselves, and just for grins, try giving them a different name, something extra unique. There could be something goofy going on with some other report setting or the way the parameters are defined.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top