Monday, March 26, 2012

Reporting Services 2005 and .NET 2003

Hello,

Can I integrate a Reporting Services 2005 report into an application done with .NET 2003, so that I can call the report from that application?

What should I consider for the deployment of the report and the application. Can I do that? (I am asking this because for the application I use framework 1.1, and for the report I use framework 2.0, don't I?)

Thanks,

Marco

Hi Marco-

You can't do that. You need VS2005 to use SSRS2005. VS2003 only works with SSRS2000.

Regards,
Scott
|||You should be able to interact with the server via SOAP and URL Access just fine from a .NET 1.1 application. What you will not be able to do is embed the Report Viewer control directly in your application.|||

You cannot design SRS 2005 reports using Visual Studio 2003, however, you can integrate/launch them from a VS2003 application. The easiest way to get this up and running is to have a copy of SRS 2005 running on your local / dev machine. I will continue assuming this is the case. I am also assuming this is probably a web application you are writing (?) because SRS is also.
My solution below. This is certainly not the only way of acheiving this, however, it will give you a good starting point I hope. I also assume you have setup SRS correctly with a data source and also know how the folder and report structure works.

1. First you will need to add a web reference for SRS 2005.

To do this, open your project and select Project > Add Web Reference from the main menu. Next click the Browse to: Web services on the local machine link. This should list all the SOAP apps on your local machine. In the list you should see ReportService. Click on the ReportService link, give it an appropriate name (the localhost default is not recommended) and click Add Reference.

2. Next, you will need to add some code to application to create the report from a stored RDL document.

I wrote this in VB.net as an example, to make it work you will need to modify it to fit your code. You will also need to add measures for the authentication mode you are using (e.g. a Shared Data Source) although this could be dealt with in the RDL. I did not have time to test this fully so be prepared to get the spade out.

Private Function MakeReport(ByVal sRDLLocalPath As String, ByVal sReportName As String, ByVal sReportFolder As String) As String

' Create reporting services object

' Possible alternate name: Dim rs As New ReportingServices2005.ReportingService2005

Dim rs As New ReportingServices.ReportingService

rs.Credentials = System.Net.CredentialCache.DefaultCredentials

rs.Url = "http://servername/ReportServer/ReportService.asmx"

' Read details of RDL from file

Dim oSR As IO.StreamReader

Dim sRDLDocument As String

oSR = System.IO.File.OpenText(sRDLLocalPath)

sRDLDocument = oSR.ReadToEnd

oSR.Close()

' Create the report on the server

Dim Warnings() As ReportingServices.Warning

Warnings = rs.CreateReport(sReportName, sReportFolder, True, StrToByteArray(sRDLDocument), Nothing)

' Check for errors

If Not Warnings Is Nothing Then

For Each Warning As ReportingServices.Warning In Warnings

If Not Warning.Message Is Nothing Then Throw New Exception("An error occured!")

Next

End If

Return "http://servername/Reports/" & sReportFolder & "/" & sReportName

End Function

3. Finally display the report in some way

Again some quick VB code to run this, using the code from above. Again, Mickey Mouse, sorry. You will need to be in an aspx.vb page and not a component class or similar to use the Response.Redirect, but there are better things you can do with the report URL as I'm sure you're probably aware.

Dim sReportURL As String

sReportURL = Me.MakeReport("c:\myreports\myreport.rdl", "MyReport1234", "MyReports")

Response.Redirect(sReportURL)

No comments:

Post a Comment