• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1611
  • Last Modified:

Adding SSRS Report Viewer to Visual Studio vb.net project

I have a vb.net project created using Visual Studio 2008.  I also have an SSRS report which requires 2 parameters (2 segments of a GL account).  The vb.net project presents a window for the user to select the 2 segments.

Now I want to pass the 2 segments as parameters to the SSRS report and then view it in the Report Viewer.

How do I add the Report Viewer to the project and how do I code the parameters to the process of launching the Report Viewer?

T
0
thoecherl
Asked:
thoecherl
  • 3
  • 2
1 Solution
 
thoecherlAuthor Commented:
OK, I've got the Report Viewer on the form now and it is finding the correct report.  However, I still have to pass the two parameters.  The Parameter Names in the SSRS report definition are @Comp and @Depart.

I will be capturing the values for the two parameters before launching the report viewer.  What is the syntax for passing those values to the report viewer?

The name of the Report Viewer is SSRS_Report_Viewer.  I think the syntax should be something like this:  SSRS_Report_Viewer.ServerReport.SetParameters().  But I don't know what to put in the parentheses.  Any ideas?

T
0
 
planoczCommented:
Can you run a stored Procedure for the report?
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
thoecherlAuthor Commented:
No.  The Report Viewer launches as soon as the form on which it resides is loaded.  Then it looks for the parameters.  There are actually 3 parameters, not 2.  I'm able to pass in the first parameter (date) but I can't get the other parameters in.  Here is my code:

    Private Sub SSRS_Report_Viewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SSRS_Report_Viewer.Load
        Dim myparams As New List(Of Microsoft.Reporting.WinForms.ReportParameter)

        myparams.Add(New Microsoft.Reporting.WinForms.ReportParameter("MonthEndDate", "9/30/2012"))
        myparams.Add(New Microsoft.Reporting.WinForms.ReportParameter("Comp", "10"))
        myparams.Add(New Microsoft.Reporting.WinForms.ReportParameter("Depart", "0002"))

        SSRS_Report_Viewer.ServerReport.SetParameters(myparams)
    End Sub

When the report launches, I get the error message: "Comp is missing a value".  If I remove the MonthEndDate parameter from the above code, I get a message saying the MonthEndDate is missing a value.  So the report is accepting that first parameter, but not the 2nd or third.

Can you see a problem with my code?
0
 
ValentinoVBI ConsultantCommented:
I'd try using a regular array instead of a List object:

Dim myparams(2) As New Microsoft.Reporting.WinForms.ReportParameter

myparams(0) = New Microsoft.Reporting.WinForms.ReportParameter("MonthEndDate", "9/30/2012")
myparams(1) = New Microsoft.Reporting.WinForms.ReportParameter("Comp", "10")
myparams(2) = New Microsoft.Reporting.WinForms.ReportParameter("Depart", "0002")

SSRS_Report_Viewer.ServerReport.SetParameters(myparams)

Open in new window

Please note that the 2 in "Dim myparams(2)" is not an error.  It indicates the upper bound of the array, not the number of items.
0
 
thoecherlAuthor Commented:
Thank you.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now