crystal parameter onlly updates first time using SetParameterValue

I am creating a heading for my crystal report in my asp.net application, then passing it to the crystal report using the setparametervalue method of the report object. In crystal, there is a parameter called 'Report_Heading' which does not allow multiple values. There is also a formula which picks this parameter up and displays it in the heading.

This works fine the first time the report displays. But when I refresh my dataset with different data and re-display the report, the heading fails to update. The data in the report is different, but the new value for the parameter is not displayed.

The attached code is in a subroutine called from page_load.

I have tried using a report.load statement, and a report.refresh, and I'm out of ideas. Can anyone help?
thanks,
Stewart
Private Sub Refresh_Report(ByVal command_text As String)
 ' (code here to populate dataset1 using sql based on dropdownlists)
  Dim headingString as string = "This Report Heading"
  Dim thisreport As New CrystalReport1
  thisreport.SetDataSource(Dataset1.Tables("myTable"))
  ' Report_Heading is the name of the parameter in the crystal report...
  thisreport.SetParameterValue("Report_Heading",headingString)
  CrystalReportViewer1.ReportSource = thisreport
End Sub

Open in new window

Stewart_in_AtlantaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jgbreedenCommented:
When you say this routine is called from page_load, and then when you 'refresh the dataset', are you calling this same routine again?  The only other thing I can think of is possibly set the report object to nothing and reload it each time.
Stewart_in_AtlantaAuthor Commented:
Hi  JGBreeden,
yes, I'm calling the same routine each time from page_load. What changes is the contents of the dropdowns and the sql that I use to generate the dataset.
I've made the following change but I get the same result - can you take a look and let me know if this is what you meant? I have replaced:
            Dim thisreport As New CrystalReport1
with:
            Dim thisreport As CrystalDecisions.CrystalReports.Engine.ReportDocument
            thisreport = Nothing
            thisreport = New CR_Customer_Listing
            Dim reportPath As String = Server.MapPath("CrystalReport1.rpt")
            thisreport.Load(reportPath)
thanks...
Stewart_in_AtlantaAuthor Commented:
Is anyone able to help me with this? I am now desparate. I would have thought the ability to pass a parameter to a Crystal report on an asp.net page would be straight forward. Perhaps someone who does this regularly could share some sample code?

thanks,
Stewart
jgbreedenCommented:
Hi Stewart,

Sorry I didn't get back, I didn't really know what else to suggest.  As I am looking at our .net code (which I didn't write, I'm better with Crystal than .net) I see that we are using a ParameterFields() object, and we are passing it to the viewer object, not the report object.  I must be a little brain dead at the moment, because that doesn't sound right to me, but here is a snippet of the code we use:

        Dim Rpt As ReportDocument
        Dim ParamFields As New ParameterFields()
        Rpt = GetReport(MyReport)

        Dim StartDateField As New ParameterField()
        Dim StartDate As New ParameterDiscreteValue()
        StartDateField.ParameterFieldName = "StartDate"
        StartDate.Value = MyStartDate
        StartDateField.CurrentValues.Add(StartDate)

        ParamFields.Add(StartDateField)
        crViewer.ParameterFieldInfo = ParamFields
        crViewer.ReportSource = Rpt

J

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Stewart_in_AtlantaAuthor Commented:
fantastic, that works fine. One thing, in case anyone else is following this... the line Rpt = GetReport(MyReport) didn't work for me.
I replaced:
        Dim Rpt As ReportDocument
        Rpt = GetReport(thisreport)
with:
        Dim rpt As New CrystalReport1
Thanks, I really appreciate the help.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.