Link to home
Start Free TrialLog in
Avatar of JAM1011
JAM1011

asked on

VB.NET crystal reports passing parameters . Report Load failed error

Hey all,
I am having trouble getting my report to run when I try and pass the parameters values via code. The report runs fine when I type the values in manually.
a message box with "Load Report Failed" come up three times. and the report doesn't load,
I am using VS 2009 PRO
Any Ideas What is wrong with the code


Thanks
James
Dim cryRpt As New ReportDocument



        Dim p1 As New ParameterFields 
        Dim p2 As New ParameterField 
        Dim p22 As New ParameterField 
        Dim p3 As New ParameterDiscreteValue         
Dim p4 As New ParameterDiscreteValue 

        p2.ParameterFieldName = "Name"
        p3.Value = "23"
        p2.CurrentValues.Add(p3)
        p1.Add(p2)
        Form1.CrystalReportViewer1.ParameterFieldInfo = p1 
      

        p22.ParameterFieldName = "Payment_ID"
        p4.Value = "55"
        p22.CurrentValues.Add(p4)
        p1.Add(p22)
        Form1.CrystalReportViewer1.ParameterFieldInfo = p1

        Form1.CrystalReportViewer1.ReportSource = "Kellihers_Lawnmowers.CrystalReport3.rpt"
        Form1.Show()

Open in new window

Avatar of Mike McCracken
Mike McCracken

Are these Crystal parameters?

mlmcc
The parameters belong to the report.  You need to assign the report source before assigning the parameters.

They need to be assigned to the report object.

mlmcc
Avatar of JAM1011

ASKER

I have placed the report source at the top of the code but is still doesn't seem to working I still get the same error . Any ideas ??


Thanks
James
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JAM1011

ASKER

Thanks for the help..

Change the line below to the following
Dim CRYRpt1 As New CrystalReport3()

 Form1.CrystalReportViewer1.ReportSource = CRYRpt1

Open in new window