Solved

ReportViewer loading/Parameter passing issue.

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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

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…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

726 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