Solved

ReportViewer loading/Parameter passing issue.

Posted on 2013-10-25
4
756 Views
Last Modified: 2013-10-29
I've been searching like crazy to figure out what I'm doing wrong and have rewritten the code below in different ways.  Just can't figure out what is missing or out of order.

I'm trying to load a 2005 rdl file to my report viewer in VS 2010 (vb).  It is actually loading the report but not the data.  What I mean is I am seeing the Report Title but the parameter is not working correctly because no data is being returned. So the Parameter is being passed as null is my guess.  When I step thru TextBox1.text is correct.

Any Ideas what I'm doing Wrong.




Public Sub LoadReport()
        Dim rds As New ReportDataSource
        Dim Param1 As New ReportParameter
        Param1.Name = "Parameter1" '*** The actual name of the parameter in the report ***
        Param1.Values.Add(TextBox1.Text)
        Dim m_DataSet = New MangeInv.dtsHistory


        Me.tbladpHistory.FillBy(Me.DtsHistory.HISTORY, TextBox1.Text)

        rds.Name = m_DataSet.DataSetName
        rds.Value = m_DataSet.Tables("History")

        ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
        Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "rptHistory.rdl"

        ReportViewer1.KeepSessionAlive = True
        With ReportViewer1.LocalReport
            .DataSources.Clear()
            .SetParameters(New ReportParameter() {Param1})
            .DataSources.Add(rds)
            .Refresh()
        End With

        Me.ReportViewer1.RefreshReport()

    End Sub

Open in new window

0
Comment
Question by:MadIce
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Expert Comment

by:planocz
ID: 39602828
Have you check the sql side?
You have to run the sql query to make sure you are getting data in return to your query.
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 39605679
Agreed.  Open up SSMS and execute the SP that is the data set for your report, with a NULL as the parameter, and see if it returns records.

Also verify in your .rdl file's data set that the parameter in the SP is correctly mapped to the parameter in the .rdl file.  It also helps to delete any unnecessary parameters if they've changed, and verify the spelling is correct.
0
 

Author Comment

by:MadIce
ID: 39606843
I was receiving the title of the report so I know it was loading.  It had something to do with the parameter but not sure what.  I rewrote the code a different way and now it works.  I had different issues at different times so not sure what finally fixed it.  Parameter was an issue at one point but I think I wasn't filling the table adapter first or I was filling it with the wrong data. I will post what worked.
0
 

Author Closing Comment

by:MadIce
ID: 39610157
appreciate the help.  This lead me into the right direction.  It was ignoring my parameter because I was pulling data from query without parameter.  Had some other issue.  I also thought why not just use LINQ query results as my data source.  Easier to deal with.  So below is my code incase some one has interested.  Table names and fields are different.

    Public Sub FillReport()
        Dim rds As New ReportDataSource()
        Dim myParam As New ReportParameter("Param1", cmbItem1.Text)
        Dim PassParam As String

        ReportViewer1.LocalReport.ReportPath = "MHistory.rdl"

        PassParam = cmbItem1.Text

        Dim MResults = From Hist In dcHistory.HISTORY _
                          Where Hist.Item1 = PassParam

        ReportViewer1.LocalReport.DataSources.Clear()

        ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local

        ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("dtsHistory", MResults))

        'report expects a parameter passed but data is already filtered.
        Me.ReportViewer1.LocalReport.SetParameters(myParam)
        ReportViewer1.RefreshReport()

    End Sub
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question