Introduction
I'm going very quickly and deeply into the integration of .aspx pages with reporting services reports. If you are new to reporting services this is not an article for you. I will show you how to integrate reports into .aspx pages and alter the content of the reports with web server controls such as drop down boxes and calendars. I take for granted you have a developer machine setup with SQL Server developer edition, Visual Studio .NET, and Reporting Services installed on your client with online samples and books installed as well. I will also not get into designing reports and placing them on your Report Server.
Get Microsoft report viewer
In the samples that are bunged with Microsoft reporting services there is a Report Viewer, this is supplied in VB as well as in C#. I will be concentrating on the C# version. The Report Viewer will allow you to display reports inline with other controls and HTML on a .aspx page.
The report viewer project can be found here:
C:\Program Files\Microsoft SQL Server\MSSQL\Reporting
Services\Samples\Applications\ReportViewer\
You can add this as a sub project to your solution or compile the project to a DLL and add that as a reference to your new reporting project. We will do the latter and add the compiled DLL to our new project.
- Open the folder ReportViewer in samples browse to cs (for C# version).
- Double click or open the ReportViewer.sln (i.e. open the ReportView solution in Visual Studio).
- Build the solution.
- Close the project.
Visual Studio has now created a few more directories including a bin directory with a debug version of ReportViewer.dll (you can change the build type to produce a release version if you want).
Configure VS to use Report Viewer
Now you can add ReportViewer.dll to this your web project and view reporting:
- Copy the ReportViewer.dll into your bin directory or your web project.
- In Solution Explorer: Right-Click references, Add a reference, Projects TAB, browse and select ReportViewer.dll in your bin directory.
- Now add a ReportViewer document to the toolbox: Right Click Toolbox, Add Remove Items, Browse to bin directory and select ReportViewer.dll.
You should have ReportViewer on your Toolbox in Visual Studio.

Simple Report Viewer on web pages
This is the real easy bit, drag ReportViewer from the Toolbox onto your webpage:

So, now we have to tell ReportView where to find a report. Right click to see the properties of the ReportViewer:

As can be seen above, I've set ServerUrl and the ReportPath. This will show the report as shown on the default webpage for reporting server except that it's encapsulated into a ASP.NET web page. Unless you specify a report ServerURL and ReportPath the component does not let you alter the size and height of the report on the web page.
Useful parameters
ServerUrl: The website server of your MS Reporting Server is installed.
ReportPath: The path on the Reporting Server with the report name (Folder/report name).
ToolBar: Turn the toolbar on or off, good for exporting to Excel, PDF etc.
Parameters: Show parameter fields to the user (i.e. input fields that drive the report data).
Zoom: Handy for printing directly from the web pages.
Top Tip: Store the ServerURL in web.config application key so that it can be used throughout your application. System administrators have a habit of changing the backend servers.
web.config
<appSettings>t;
<add key="Key_ReportServer"
value="http://myServer/reportserver"/>
</appSettings>
C# code
private void Page_Load(object sender, System.EventArgs e)
{
ReportViewer1.ServerUrl =
(ConfigurationSettings.AppSettings["Key_ReportServer"]);
}
Build a parameter report
Some reports take parameters and you detail what information is to be displayed by the start date, year, end date etc. I generally use SQL Server stored procedures to drive reports as I can change the backend SQL logic without the hassle of uploading and changing the report.
Below is a very simple stored procedure used to get the Order Qty (number of orders) over a set year. The SQL is included for reference:
CREATE PROCEDURE usp_SalesQty
@Year as int
AS
select * from Ord_Qty
Where YearInt = @Year
GO
I have put this in a simple report that displays a table by Month and Year with a Qty value. I also placed a chart on the report to show the quantity of sales by month. I have uploaded Report5.rdl to my Reporting Services server called in a test directory. Note that when the report is created by using the above stored procedure it will pull the parameter @Year as a report parameter automatically.
There are two ways I could view the report on the web page: Enter report details into parameters as shown above or use the code to tell the ReportViewer component where to find the report. Since we're all programmers I will use the code.
Change the report with the code
ReportViewer1.ServerUrl =
(ConfigurationSettings.AppSettings["Key_ReportServer"]);
ReportViewer1.ReportPath = "/test/Report5";
Specify the Parameters of the Report component what the ServerUrl and the ReportPath are and the report will appear on the screen on build on browse. You still have to enter a year into the Parameter field just like going to reporting services directly; which is a bit crude for users, the toolbar is visible we will turn those off so that they are hidden from the user.
ReportViewer1.Toolbar =
Microsoft.Samples.ReportingServices.ReportViewer.multiState.False;
ReportViewer1.Parameters =
Microsoft.Samples.ReportingServices.ReportViewer.multiState.False;
Top Tip: You have a single ReportViewer component that can be used to display more than one report.
Integrating web components
By placing a drop down list onto the web page and setting three variables (2002, 2003, 2004) we can use this to drive the Report parameter. You will have to ensure that autopostback is enabled on the drop list control.
private void DropDownList1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
string param = "&Year=" + DropDownList1.SelectedValue;
ReportViewer1.ReportPath = "/test/Report5" + param ;
}
A more complex example is here pulling the date info from a calendar control and a drop down:
string ReportPath = "/Reports/Invoice";
string param = "&Year=" + yearint + "&Month=" + monthint
+ "&Day=" + dayint +
"&Cust=" Drop_Cust.SelectedValue;
ReportViewer1.ReportPath = ReportPath + param ;
Turning on toggle toolbar
You can also place a web control button on your page to toggle the toolbar on and off.
private void Button1_Click(object sender, System.EventArgs e)
{
ReportViewer1.Toolbar =
Microsoft.Samples.ReportingServices.ReportViewer.multiState.False;
}
Page view

Complete code
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
namespace ReportWeb
{
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.Button Button1;
protected Microsoft.Samples.ReportingServices.ReportViewer ReportViewer1;
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
string param = "&Year=" + DropDownList1.SelectedValue;
ReportViewer1.ReportPath = "/test/Report5" + param ;
ReportViewer1.ServerUrl =
(ConfigurationSettings.AppSettings["Key_ReportServer"]);
ReportViewer1.Toolbar =
Microsoft.Samples.ReportingServices.ReportViewer.multiState.False;
ReportViewer1.Parameters =
Microsoft.Samples.ReportingServices.ReportViewer.multiState.False;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.DropDownList1.SelectedIndexChanged +=
new System.EventHandler(this.DropDownList1_SelectedIndexChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DropDownList1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
string param = "&Year=" + DropDownList1.SelectedValue;
ReportViewer1.ReportPath = "/test/Report5" + param ;
}
private void Button1_Click(object sender, System.EventArgs e)
{
ReportViewer1.Toolbar =
Microsoft.Samples.ReportingServices.ReportViewer.multiState.False;
}
}
}
History
| You must Sign In to use this message board. |
|
|
 |
|
|
 |
|
 |
According to what I understand reportviewer sample is supposed to be in the folder reporting services\samples in my computer. it is not and though we have a few intalation disks it doesnt add it in instaltion. I found reportviewer.dll in the internet, but it is missing the property serverreport, localreport. could any one send me please the sample, or the reportviewer.dll. I use .net 2 sql server 2005
-- modified at 3:07 Thursday 30th November, 2006
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
If you are using 2000 then install the samples on your desk top with the help and tuts.
If you are using 2005 then you have to download the ReportViewer project via MS website
Hope this helps.
Blog Have I http:\\www.frankkerrigan.com
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
Hi, I have a report tha calls a stored procedure from my database, but I have to set value to the procedure parameter, if i have a text parameter on the report the value would be something like @@Date=Parameters!Date.Value but if I want to use the parameter sent, like in this example, with the web controls how would it be?? I'm using a data set, with a query string that is the stored procedure. Hope you understand what my problem is, Thanks
Sergio
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
I had added ReportViewer component in my .NET 2003 toolbox but this component is disabled or passive. How can I activate this control? Thanks for your answers....
This is my sign
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Sorry it seemed to work fine for me. Read the manual that came with the sample. Sorry I'm not much help I've moved jobs and no longer use reporting services.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Now I finally have an understanding of how to create simple reports from my dataset. I now wonder how I can make custom (SQL-queries) on my dataset that will fill for e.g. a table.
For example I have a picture that I like to insert into my report. That picture do I store as a string in my database. (In my program I do conversions functions for: Image -> byte[] -> string -> byte[] -> Image).
_____________________________
...and justice for all
APe
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
 | Chart  Tuaregue | 1:59 11 May '06 |
|
|
 |
|
 |
I'm noit sure what you mean. The chart is driven by the back end SQL Server Stored Procedure.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi.. I have reports which are designed in Reporting Services 2000. Despite i have built them all i dont have any bin folder in the project folder. So i dont have any dll about the reporting services..So i couldnt add the ReportViewer tool to my toolbox... I really need to add a pie chart which i prepared in RS to a asp.net page... But i couldnt achieve to my goal becouse i couldnt be able to add the report viewer tool to the toolbox.... Any suggestion?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
You must follow the installation instructions that are supplied with Reporting Services books online under samples.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
ok thank you But this time i have bigger problem... When i try to add a chart to my Report Designer i saw that CHART item is not in the toolbox...I try to add Dundas Chart's dll but when i add it to the toolbox this time the chart icon looks disabled and i couldnt add it into the report designer... I dont know how will i handle this problem I uninstalled the Report Designer 2 times and Re-install it but despite Image Lıne Matrix Rectangle Subreport Table and Textbox are there there is not any CHART item
What should i do:(
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
This sounds like a problem with the reporting services toolbox chart item within Visual Studio. Have you contacted Microsoft support over this issue as this sounds like a Visual Studio issue? Do you have a version of Dundas Chart loaded in the GAC or copied in another Visual Studio folder other than the “PrivateAssemblies” folder (say, the “Common7” or “IDE” folder)?
SQL RS deploys a version of chart control (that they built) with a different version number and signature but having the same name as our product controls (this is normally in the “PrivateAssemblies” folder. If you copied a version of our asp.net or winfoms control over top of the one deployed by SQL, then this is probably the cause of your problems. If you did, you will be able to find the SQL version of the control in the report server bin folder and should copy it back. This is normally:
C:\Program Files\Microsoft SQL Server\MSSQL.x\Reporting Services\ReportServer\bin
To get the native chart report item back in the toolbox, right click on the toolbox panel and select reset. If this does not work you may need to delete VS temporary toolbox files. These are found in a hidden folder and can be found:
C:\Documents and Settings\\Local Settings\Application Data\Microsoft\VisualStudio\8.0
Ensure Visual Studio is not running and delete all of the toolbox*.tbd files. The next time you load VS it will regenerate all of the toolbox items. USE THIS AS YOUR LAST RESORT! If you have any other 3rd party controls loaded in a toolbox, they probably will not be there anymore.
I hope this helps, and good luck!
Andrew Bryan Program Manager, Dundas Chart for Reporting Services
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi andrew... i have DundasWebChart.dll in this path; C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\bin Assembly version of the dll is 3.6.0.1634 After right clicking on the Toolbox for adding a new item i browse to this path and trying to add this dll..It is adding it but it is passive...as like as a disabled control
and C:\Documents and Settings\osman.ayhan\Application Data\Microsoft\VisualStudio\ at this path i dont have the 8.0 folder.I have 7.1 folder.And in it there is not any file whose extension is tbd...And in my local disk there is not even any *.tbd file!!!U said
"Ensure Visual Studio is not running and delete all of the toolbox*.tbd files. The next time you load VS it will regenerate all of the toolbox items. USE THIS AS YOUR LAST RESORT! "
So even for my LAST RESORT it doesnt work:(
What should i do..
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi andrew.. Good News... I could reset the Toolbox this time.. Guess? I have my chart item again
Thax a lot for your support
Osman AYHAN SOFTWARE ENGINEER TR
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I have made a report and deploy it to report server on my local machine. And I can view the report in browser with http://localhost/reportserver or http://localhost/reports. But when I tried to access report from my VS web page, it gives error like the "mymachinename/ASPNET" has no permissions to do this operation. I have default settings in my report server (sevices credentials). And I set windows integrity security in my IIS for report server, repots and my web application. What shall I do if I want all user in our intranet can use the web page to access the report without any login and password.
Thanks for any help
Andrea
adb96hxo
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
ASPNET user is the default user that runs ASP server process. Ensure you have Anonynous (forgive my spelling) turned off for the "reportserver" virtual directory. This is the one you want to give out to your users / place on ASP.NET pages.
http://servername/reportserver/Directory/reportname
Try and browse to the report via the reportserver virtual directory to see if you can see it from other machines.
You also might have to look at permissions on your SQL server connection and set this to a SQL user rather than a username password supplied by the client. I've had issues with dialup user / vpn users not suppling correct Kerboros authenication for reports embeded in sharepiont webpars.
If your intranet is a wan you can have issues with Kerboros through firewalls / routers.
Hope this is of somehelp
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thankx for your tips. I have clear the checkbox for anonymous for the reportserver i IIS and I can see the report from other machines too.
Sorry I don't know really what you mean with setting permissions in SQL server. Because my web application use defualt user mymachinename\ASPNET, so I tried to add this user to both sql server and report server database user and give this connect rights. But still doesn't work. I know very little about sql server. So please help!
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
OK,
It depends on how you attach your reports to SQL server. If you want to use anonymous connections you have to setup your report to supply a SQL server username and password that has the permissions to run the SQL query for the report. You may have already set this up.
|
| Sign In·View Thread·PermaLink | 1.20/5 |
|
|
|
 |
|
 |
Frank, I have the same problem:I integrated the report in the web page, but it asks me for my windows password or reporting services password. What exactly do I do to let users see it? Thanks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
First of all thanks for such a nice article on Report View control. But i just want to list out some of the limitation of Reporting services. 1. What about Forms authentication 2. What if i don't want to provide access to my reporting service server and want to provide through proxy server.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Sorry but I can't defend limititions with Reporting services.It is free qirg SQL server and great for intranets.
1. The forms authenication might be addressed with SQL Server 2005. 2. We use reporting services thru a proxy server with no problems.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I've started using the Reporting Services Web Service api and am quite pleased with the results. I am able to use forms authentication running against sql to handle authentication and authorization (which reports a user can view, what parameters they see). I dynamically load the parameters and their option values (if they exist) and give pdf and/or excel format options (again based on their authorization). When they click the submit button, I pass all of the relevenet info to the RS web service and get a stream back which I redirect to the Response Stream. I used the examples provided in the book "Hitchhicker's Guide to SQL Server 2000 Reporting Services."
I am really hoping for improvements in SQL 2005. I feel that the first version was a good start, but there is room for improvement. A report viewer control based on the Web Service would have been nice.
Adam
|
| Sign In·View Thread·PermaLink | 4.00/5 |
|
|
|
 |
|
|