This is the 6th of 7 articles on SSRS. For a brief recap you can find them here:
Part 1 – Arvixe and Reporting Services Intro
Part 2 – Arvixe and Reporting Services Verify
Part 3 – Arvixe and Reporting Services Deploy
Part 4 – Arvixe and Reporting Services Consuming Options
Part 5 – Arvixe and Reporting Services Direct URL
This article is to provide an example of how to use VS2012 Report Viewer against an Arvixe SSRS Server. As I have said before many of the points in these articles can be used regardless of the hosting solution but if you host with Arvixe you should find all of these articles very relevant.
After you have deployed a report you can process and view the report in two ways. Today I want to give you an example of how to use the ReportViewer to display a report in a web page.
Step 1. Launch VS2012 and create a blank web application project. Let’s Call it SSRSArvixeReportViewer (Pretty original).
Step 2. Once you have done that than add a web page and call it ShowReport.aspx. Once you are done it should look something like this. (Figure 1)
Step 3. Open the Showreport.aspx and drag the reportviewer control and the script manager control. The need for the reportViewer control should be obvious but the script manager control is used for running the report Asynchorously. When you are done it should look something like this. (Figure 2) This process of adding these controls will also make changes to your web.config. (See Figure 3)
Step 4. You are ready to consume your report from Arvixe SSRS. There are a couple of things to keep in mind. When you are consuming a report you must pass the login and password that Arvixe gave you. This will give your application the necessary credentials to run the report. In order to do this I found this nice little class that you can add to your project that helps in passing these credentials. I actually got it from here. Now that you have this, the rest is just setting the parameters and writing a few lines of code in the code behind of the form. (See Below). To keep with the same account information from the prior articles (You will receive something similar to this when you subscribe to SSRS with Arvixe (Figure 4))
Public Class _Default
Private Sub _Default_Init(sender As Object, e As EventArgs) Handles Me.Init
If Not Page.IsPostBack Then
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote
ReportViewer1.ToolBarItemBorderColor = System.Drawing.Color.PowderBlue
ReportViewer1.ToolBarItemBorderStyle = BorderStyle.Double
Dim strUserName As String = "angler2be_report"
Dim strPassword As String = "1Password1"
Dim strDomain As String = "trout.arvixe.com"
ReportViewer1.ServerReport.ReportServerCredentials = New ReportCredentials(strUserName, strPassword, strDomain)
ReportViewer1.ServerReport.ReportServerUrl = New Uri("http://trout.arvixe.com/ReportServer_SQL_service")
ReportViewer1.ServerReport.ReportPath = "/BestFishingSpot" ‘Name of Report
ReportViewer1.AsyncRendering = True
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
A few special notes regarding this.
* When the AsyncRendering property is set the False the ReportViewer will render the report as inline HTML. Since the HTML is inline, the rest of the page will be blocked while the report is processed and rendered.
* If you place the above code in the Load Page it will keep calling the report over and over again. You need to place it in the init part of the page and check for postback.
That’s it! If you are going to add parameters just make sure that the parameters are set before rendering the report or you will get an error.
As promised you can download the sample project SSRSArvixeReportViewer.
Looking for quality web hosting? Look no further than Arvixe Web Hosting!