Link to home
Start Free TrialLog in
Avatar of ljhodgett
ljhodgett

asked on

Error when passing parameters to Crystal Reports

Hi Experts,

I have the following code: -

        Dim dr As DataRow = DSTPurchaseOrder.Tables(0).NewRow
        dr(0) = "1"
        dr(1) = "2"
        dr(2) = "3"
        dr(3) = "4"
        dr(4) = "Another"
        dr(5) = "6"
        dr(6) = "7"
        dr(7) = "8"
        DSTPurchaseOrder.Tables(0).Rows.Add(dr)
        rpt.SetParameterValue("Company Name", txtCompanyName.Text)
        rpt.Load(Forms.Application.StartupPath & "\PurchaseOder.rpt")
        rpt.SetDataSource(DSTPurchaseOrder.Tables(0))
        CrystalReportViewer1.ReportSource = rpt

I am trying to populate a crystal report using vb.net 2005 with crystal reports bundelled with it. When the for loads despite me adding a paramter name “Company Name” when I send data to it it does not seem to work as when the report loads it says: -

Enter Parameter Values.
You can provide a single value for this paramter. Enter the value you want to include for “Company Name”

What am I doing wrong please. Sorry I am new to crystal reports.

Many Thanks
Lee
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 ljhodgett
ljhodgett

ASKER

Hi Mlmcc,

Thank you for that I'll accept your answer. Out of curiosity why does it have to be set after the datasource.

Many Thanks
Lee
I don't know.  That was basically a guess.

I suspect resetting the data source may reswet the parameters.

mlmcc
Glad i could help

mlmcc