Solved

ReportViewer loading/Parameter passing issue.

Posted on 2013-10-25
4
744 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
  • 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Time Corrections for Reports Working with a report, we made some interesting discoveries about the time corrections/updates We are using the following Parameters: Starting Entered Date (Date) formatted as Data type: "Date/Time" Ending Entered …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now