0
votes

In reference to this article: http://msdn.microsoft.com/en-us/library/ms252072(VS.80).aspx

I can access my SSRS report from my Web Application but the problem is it does not accept the parameters in the URL.

here is the format that it accepts

Report Server URL: http://ABCD.com/reportserver Report Path: /Company works/Sales report/ABC

Can anyone help me? I want to pass parameters in the SSRS url through report viewer.

2

2 Answers

3
votes

You can not pass parameters via the URL since the control is expecting on the URL to the actual reportserver and nothing more.

Example: serverReport.ReportServerUrl = new Uri("http://ABCS.com/reportserver"); serverReport.ReportPath = "/AdventureWorks Sample Reports/My Report";

You can pass these parameters in your code behind though by using the ReportViewer.ServerReport.SetParameters() function. Here is a snippet of code I used for this purpose:

var parametersCollection = new List<ReportParameter>();
//add generic parameters that every report needs
parametersCollection.Add(new ReportParameter("RandomizerString", new Random().Next().ToString(), false));
parametersCollection.Add(new ReportParameter("MachineName", Request.UserHostAddress.ToString(), false));
ERDashboard.ServerReport.SetParameters(parametersCollection);
1
votes

can't seem to add a comment to Sam's answer so I'll post another:

The ReportViewerControl ReportServerURL property is a lot different than formatting a general URL to access a report. You could use the logic that sam has provided to navigate a web browser control to that URL which would also render the report within your web app. It's another to try if you want.

As a note there are various reasons that you may choose a webbrowser control vs a reportviewer control. The reportviewer control is a lot easier to manage in the code-behind, but there is a memory issue when refreshing a report for extended periods of time (lots of information through google about memory leaks). This is the scenario where I have instead used the webbrowser and manually formatted URLs to pass parameters instead.