?
Solved

ReportViewer loading/Parameter passing issue.

Posted on 2013-10-25
4
Medium Priority
?
770 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 66

Accepted Solution

by:
Jim Horn earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

How to use Variables  and Custom code in SSRS report and Assembly reference to use compile shared code in SSRS. Its big question for all who are working with SSRS. It is easy to create assembly and refer in SSRS report, still there are some steps…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

765 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