Solved

Trying to display SSRS report with parameters from ASP.NET (VB) page

Posted on 2013-12-05
4
692 Views
Last Modified: 2013-12-22
I have deployed 2 SSSRS reports to my localhost report server - one has a parameter, the other does not. When viewed through localhost/Reports, both reports are fine. For the parameterized report there is a prompt for my parameter and the report displays correctly.

Now I want to open this report from an asp page. The code works fine for the non-parameterized report.  The parameterized report, however, throws a javascript error when it hits the Refresh command and the report tries to open.  Interestingly, if I comment out the code for setting the parameter values, the report opens as it would when viewed through LocalHost/Reports but as soon as I type in the parameter, an error is thrown.

So I'm thinking the problem is not so much in the code, but perhaps some linkage between my web application and the report server, but I have no idea what to look at.

Here is the code:

Imports Microsoft.Reporting.WebForms
Public Class ReportViewer
    Inherits System.Web.UI.Page

Private Sub DisplayBlendSheet()
ReportViewer1.ServerReport.ReportServerUrl = New System.Uri("http://localhost/ReportServer")
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote
ReportViewer1.ServerReport.ReportPath = "/PTS Reports/Blend Sheet"
Dim rptParams As New System.Collections.Generic.List(Of Microsoft.Reporting.WebForms.ReportParameter)
rptParams.Add(New Microsoft.Reporting.WebForms.ReportParameter("BlendID", "BN13290"))
ReportViewer1.ServerReport.SetParameters(rptParams)
ReportViewer1.ServerReport.Refresh()
End Sub
End Class

Open in new window


The error I get is not very informative (to me anyway):
JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 404

Any help would be much appreciated.
0
Comment
Question by:Lisa412
  • 2
4 Comments
 
LVL 27

Expert Comment

by:planocz
ID: 39704492
This may help; it is written in VB.net
this code will produce a pdf ssrs report.

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_26665879.html
0
 

Accepted Solution

by:
Lisa412 earned 0 total points
ID: 39725031
I finally found a solution which I will share here because I hate when I find a problem just like mine without an answer!

The problem has something to do with the way the ReportViewer control is rendered in VS 2010. It goes through several postbacks in its process. So the code to set up the report and set the parameters must be prefaced by an IsPostBack check, else it just goes into an endless loop.

That's what mine was doing anyway. Now it opens fine, with or without parameters.

Now I can't get it to close properly, but I'll open a separate question for that :)

Thanks to planocz for trying to help. I really wanted to be able to use the features of the report viewer, not just create a pdf.
0
 

Author Closing Comment

by:Lisa412
ID: 39734460
My solution allows me to open report in report viewer, not pdf
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

911 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

16 Experts available now in Live!

Get 1:1 Help Now