Solved

ReportViewer loading/Parameter passing issue.

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Written by Valentino Vranken. Introduction: The first step of creating a SQL Server Reporting Services (SSRS) report involves setting up a connection to the data source and programming a dataset to retrieve data from that data source.  The data…
Hi All, I am here to write a simple article to move SSRS (SQL Server Reporting Services) reports from one server to another. When I have faced the same issue to move reports those were developed by developer on development server and now need to …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 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