This is a migrated thread and some comments may be shown as answers.

Setting parameters in a report book not working

2 Answers 147 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Amy
Top achievements
Rank 1
Amy asked on 15 Jul 2009, 02:27 PM

I am having trouble with a ReportBook.  The reports I am using are in a class, and they work fine if I set them up to show in a regular Report Viewer with the below code (the parameters are used in the NeedDataSource in the report):

    Dim report As Telerik.Reporting.Report = Nothing
        report = New LRSummary()
        If Not report Is Nothing Then
            If Not Me.txtPolNum.Text Is Nothing Then
                report.ReportParameters(0).Value = Trim(Me.txtPolNum.Text)
            End If
            If Not Me.txtAcctNum.Text Is Nothing Then
                report.ReportParameters(1).Value = Trim(Me.txtAcctNum.Text)
            End If
            If Not Me.txtSaleNum.Text Is Nothing Then
                report.ReportParameters(2).Value = Trim(Me.txtSaleNum.Text)
            End If
            If Not Me.Linid.Text Is Nothing Then
                report.ReportParameters(3).Value = Trim(Me.Linid.Text)
            End If
            If Not Me.txtParentAgent.Text Is Nothing Then
                report.ReportParameters(4).Value = Trim(Me.txtParentAgent.Text)
            End If
            If Not Me.txtSubAgent.Text Is Nothing Then
                report.ReportParameters(5).Value = Trim(Me.txtSubAgent.Text)
            End If
            If Not Me.LimitEffective.Text Is Nothing Then
                report.ReportParameters(6).Value = Trim(Me.LimitEffective.Text)
            End If
            If Not Me.LimitExpiration.Text Is Nothing Then
                report.ReportParameters(7).Value = Trim(Me.LimitExpiration.Text)
            End If
        End If
        Me.ReportViewer1.Report = report

But if I use the below code to try to use the same report in a report book, it doesn't work.

       Dim reportBook As New ReportBook()
        Dim report As Telerik.Reporting.Report = Nothing
        report = New LRSummary()
        If Not report Is Nothing Then
            If Not Me.txtPolNum.Text Is Nothing Then
                report.ReportParameters(0).Value = Trim(Me.txtPolNum.Text)
            End If
            If Not Me.txtAcctNum.Text Is Nothing Then
                report.ReportParameters(1).Value = Trim(Me.txtAcctNum.Text)
            End If
            If Not Me.txtSaleNum.Text Is Nothing Then
                report.ReportParameters(2).Value = Trim(Me.txtSaleNum.Text)
            End If
            If Not Me.Linid.Text Is Nothing Then
                report.ReportParameters(3).Value = Trim(Me.Linid.Text)
            End If
            If Not Me.txtParentAgent.Text Is Nothing Then
                report.ReportParameters(4).Value = Trim(Me.txtParentAgent.Text)
            End If
            If Not Me.txtSubAgent.Text Is Nothing Then
                report.ReportParameters(5).Value = Trim(Me.txtSubAgent.Text)
            End If
            If Not Me.LimitEffective.Text Is Nothing Then
                report.ReportParameters(6).Value = Trim(Me.LimitEffective.Text)
            End If
            If Not Me.LimitExpiration.Text Is Nothing Then
                report.ReportParameters(7).Value = Trim(Me.LimitExpiration.Text)
            End If

        End If
        reportBook.Reports.Add(New LRSummary())
        Me.ReportViewer2.Report = reportBook
       
        I add more reports, but in the same way.  I get either no data or errors on the parameters.  If I set some sample parameters in the report class itself, the reports work, but with those sample parameters instead of the ones I set in code.  I almost feel like I should rebind the datasource somehow, but I don't seem to be able to access the report's datasource.  Plus why would I have to do that on the report book but not the report viewer?  Any ideas what I am doing wrong?

Thanks, Amy 
       

2 Answers, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 20 Jul 2009, 08:32 AM
Hello Amy,

You're setting the values for the report parameters to the local variable "report". However at the end you're not adding this report to the reportbook, but rather adding new instance of the LRSummary report, which of course would know nothing about the param values you've set. So change that line to:

reportBook.Reports.Add(report)

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Amy
Top achievements
Rank 1
answered on 22 Jul 2009, 03:02 PM
Wow. Duh.  Sorry for posting such an obvious question.  Once I read your answer it was crystal clear...unfortunately I just kept looking at it without seeing that.  Guess I need a vacation!  Thanks very much.
Tags
General Discussions
Asked by
Amy
Top achievements
Rank 1
Answers by
Steve
Telerik team
Amy
Top achievements
Rank 1
Share this question
or