Well this is my final article on Arvixe and Microsoft Reporting Services (maybe). If you have been following my articles you know that we have worked up to this last article. To say that “I saved the best for last” is probably not far from reality. Consuming a Reporting Service Report using the Report Viewer as in this article is fairly simple to do but I believe the real integration with your web site comes from consuming the web service portion of Reporting Services. This provides you with complete control and integration with your web application. You can also use Reporting Services to return an Excel Document without the user knowing that you are using SSRS to do the heavy lifting. There are also other reasons to do this which I will discuss as we build this example.
To be honest I have written a prior example on how to do this here, but since I am have used an “Arvixe Account” for my other articles, I thought I would refresh my prior article (many months ago) with this “Arvixe account” along with a few new things. As I have used in the prior examples we are assuming that ARVIXE sends you something like this after you have subscribed to SSRS through ARVIXE.
Let’s get started:
Step 1: Launch VS2012 (or like version) and Create a blank web Application.
Step 2: Add new form and call it ‘ShowReport.aspx’. When you’re done your project should look similar to this (Figure 1)
Step 5: Enter URL (Using the SSRS Information that Arvixe sent you would enter.
” http://trout.arvixe.com/ReportServer_SQL_Service/ReportExecution2005.asmx” (without quotes) and press the little icon to the right. If everything works you should see something like Figure 4 (where it finds 1 Service). If you do then click on Add Reference.
The hard part is done…Now go to your code behind page on the page created in step 2 and add the following two sections; (Pay Attention to the parameters toward the top part of the code.)
Section 1: Add to the top of the page
Section 2: Add to the Page Load section
Dim rs As ReportExecutionService = New ReportExecutionService
‘——SET PARAMETERS AND REPORT SETTINGS—-
Dim reportPath As String = "/ReportName"
rs.Url = "http://trout.arvixe.com/ReportServer_SQL_Service/ReportExecution2005.asmx?wsdl"
‘Add a NetworkCredential instance to CredentialCache.
rs.Credentials = New NetworkCredential("angler2be_report", "1Password1", "trout.arvixe.com")
Dim execInfo As ExecutionInfo = New ExecutionInfo()
Dim execHeader As ExecutionHeader = New ExecutionHeader()
Dim historyID As String = Nothing
Dim extension As String = ""
Dim mimeType As String = ""
Dim encoding As String = ""
Dim warning As Warning() = Nothing
Dim streamID As String() = Nothing
Dim result() As Byte = Nothing
‘Dim ReportParams(2) As ParameterValue
‘ReportParams(0) = New ParameterValue()
‘ReportParams(0).Name = "ParameterName"
‘ReportParams(0).Value = "ParameterValue"
‘ReportParams(1) = New ParameterValue()
‘ReportParams(1).Name = "ParameterName2"
‘ReportParams(1).Value = "ParameterValue2"
‘ReportParams(2) = New ParameterValue()
‘ReportParams(2).Name = "ParameterName3"
‘ReportParams(2).Value = "ParameterValue3"
Dim ReportHistoryParameters As ParameterValue() = Nothing
Dim devInfo As String = "False"
rs.ExecutionHeaderValue = execHeader
execInfo = rs.LoadReport(reportPath, historyID)
result = rs.Render("PDF", devInfo, extension, mimeType, encoding, warning, streamID)
Response.ContentType = "application/pdf"
NOTE 1: I have commented out the parameters. If you have any you can add them here.
NOTE 2: Also keep in mind you can use this on other events and export to other formats. I just wanted it to be very simple so that you know that there really isn’t any then special happening.
That’s it. If you have problems with this then read this article to make sure that SSRS has been set up properly.
Looking for quality web hosting? Look no further than Arvixe Web Hosting!