Kato Martin

Kato Martin

  • NA
  • 5
  • 6.7k

Crystalreports parameter error

Sep 24 2012 7:47 AM

Hi everyone,

I hope your all alright. I am trying to generate a crystal report with the same bank account id " bankacid"

Below is the code I am using.

crystalReportViewer4.Visible = true;

 

 

{

                ReportDocument cryRpt = new ReportDocument();

                cryRpt.Load("C:/Users/katoto/Documents/Visual Studio2010/Projects/Genesis Philcollins/Genesis Philcollins/CrystalReport1.rpt");

 

 

                ParameterFieldDefinitions crParameterFieldDefinitions;

                ParameterFieldDefinition crParameterFieldDefinition;

                ParameterValues crParameterValues = new ParameterValues();

                ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

 

 

                crParameterDiscreteValue.Value = textBox2.Text;

                crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;

                crParameterFieldDefinition = crParameterFieldDefinitions["bankacid"];

                crParameterValues = crParameterFieldDefinition.CurrentValues;

 

                crParameterValues.Clear();

                crParameterValues.Add(crParameterDiscreteValue);

                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

 

                

                crystalReportViewer4.ReportSource = cryRpt;

                crystalReportViewer4.Refresh();

}

 

However when I run I get the following message ( " COMException was unhandled" Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX)))

Kindly help me if you can.

Kind regards.kato