• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1542
  • Last Modified:

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

0
Stewart_in_Atlanta
Asked:
Stewart_in_Atlanta
  • 3
  • 2
1 Solution
 
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.
0
 
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...
0
 
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
0
 
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
0
 
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.

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now