Click here to Skip to main content
15,912,457 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use Crystal Report in Visual Studio 2005. But I want to generate report with two parameters those are passed from two text box. Depending on two Values, report should be generated. Can you help to bind the database with any example.
Posted
Updated 1-Aug-12 3:11am
v2

In one of my projects I am doing it like this :

public ReportForm(RapportType kind)
        {
            InitializeComponent();
            switch (kind)
            {
                case RapportType.VoorschotRapport: this.crystalReportViewer.ReportSource = this.crVoorschotReport1; break;
                case RapportType.FactuurRapport: this.crystalReportViewer.ReportSource = this.crFactuurReport1; break;
                case RapportType.KlussenRapport: this.crystalReportViewer.ReportSource = this.crKlussenReport1; break;
                case RapportType.FactuurOpstellingsRapport: this.crystalReportViewer.ReportSource = this.crFactuurOpstellingsReport1; break;
                case RapportType.ServiceAanvragenRapport: this.crystalReportViewer.ReportSource = this.crServiceAanvragenReport1; break;
                case RapportType.UitvoerbareKlussenRapport: this.crystalReportViewer.ReportSource = this.crUitvoerbareKlussenReport1; break;
                case RapportType.DringendeDossiersRapport: this.crystalReportViewer.ReportSource = this.crDringendeDossiersReport1; break;
                case RapportType.AfwerkingsRapport: this.crystalReportViewer.ReportSource = this.crAfwerkingsReport1; break;
                case RapportType.RetourRapport: this.crystalReportViewer.ReportSource = this.crRetourReport1; break; 
            }
        }

        public ReportForm(RapportType kind, string filter, string filter2, string instance)
            : this(kind)
        {
            this.filiaalFilter = filter;
            this.dossierBeheerderFilter = filter2;
            this.Instance = instance;
            CrystalDecisions.Shared.ParameterField filiaalField = crystalReportViewer.ParameterFieldInfo["InputFiliaal"];
            CrystalDecisions.Shared.ParameterField dossierBeheerderField = crystalReportViewer.ParameterFieldInfo["DossierBeheerder"];
            CrystalDecisions.Shared.ParameterField instanceField = crystalReportViewer.ParameterFieldInfo["Instance"];
            CrystalDecisions.Shared.ParameterDiscreteValue value = new CrystalDecisions.Shared.ParameterDiscreteValue();
            if (filiaalFilter.Contains(","))
            {
                string[] filters = filiaalFilter.Split(',');
                foreach (string f in filters)
                {
                    filiaalField.CurrentValues.AddValue(f);
                }
            }
            else filiaalField.CurrentValues.AddValue(filiaalFilter);
            dossierBeheerderField.CurrentValues.AddValue(dossierBeheerderFilter);
            instanceField.CurrentValues.AddValue(Instance);
            crystalReportViewer.Refresh();
        }


So first set the reportsource.
Then you get the different CrystalDecisions.Shared.ParameterFields and assign a value to them.
refresh the report. It works for me.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900