Visual Studio 2010 calling SQL 2005 Reporting Services

I have SQL 2005 reporting services that host a couple of reports. In the past I’ve been able to access these report via a web page built in Visual Studio 2005. However, a recently created web application in Visual Studio 2010 has caused me some grief. I ran into issues with reports not being displayed, to JavaScript errors, etc.

Using the ReportViewer control in VS2010 allows running of remote SQL reports from report server 2008 and above http://msdn.microsoft.com/en-us/library/bb885185.aspx. This is where I ran into my first issue since my remote report was in SQL 2005 Reporting Services. Anyway, here is how I went about executing a SQL 2005 Report from a web page within Visual Studio 2010. Hope this helps.

1. From VS2010, create a new ASP.NET web application. By default this will target .NET Framework 4.

2. We will work with the "Default.aspx" page here. Open the page’s source code and add the following code just under the "page" directive.

Code Snippet
  1. <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
  2.     Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

3. Add the following code where you want the report displayed. I have a report named "MyReport" under a folder "Reports".

Code Snippet
  1. <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
  2.     Height="400px" ProcessingMode="Remote" Width="400px">
  3.     <ServerReport ReportPath="/Reports/MyReport" ReportServerUrl="http://myserver/ReportServer$SQL2005&quot; />
  4. </rsweb:ReportViewer>

4. In the project references, add the reference to "Microsoft.ReportViewer.WebForms 8.0.0.0 v2.0.5.727".

5. In Web.Config, add the following within the "System.Web" section.

Code Snippet
  1. <httpHandlers>
  2.   <add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  3. </httpHandlers>

6. Run your web page in the browser and hope you see the report as I do.

Good luck!

Advertisements