DATABASE

Reporting Services with SQL Azure : Deploying the Report & Creating a Subreport

1/24/2011 4:56:10 PM

1. Deploying the Report

Currently, you can't deploy a report to Azure, so all reports must be deployed locally. To deploy a report, follow these steps:

  1. Right-click the report solution, and select Properties from the context menu.

  2. In the Property Pages dialog, the only thing you need to enter is the TargetServerURL, shown in Figure 1. Notice also the name of the TargetReportFolder, which in this case is AzureReports—the name of your Visual Studio solution.

  3. Right-click the solution in Solution Explorer, and select Deploy from the context menu.

  4. When the report has deployed successfully, open your browser, and navigate to http://[machinename]/Reports. You should be presented with your SQL Server Reporting Services Home folder and the AzureReports folder. In the AzureReports folder is your newly created Documents report. To view the report, click the link for it.

You just walked through a simple example of creating a report that pulls data from SQL Azure. Let's modify it to add a subreport that pulls data from the on-premises database.

Figure 1. Solution Property Page

2. Creating a Subreport

Your report is called Documents, but it displays users—and that's why you're going to add a subreport. You want to display all documents for the related users (one user can have multiple documents). To do this, you need to create another report and, along with it, a new data source and dataset. This time, however, you want to pull the documents from your on-premises database. Thus, the users come from SQL Azure, and the related documents from your on-premises database. Follow these steps:

  1. You need to create the subreport to display the documents. Create a new report and an associated data source and dataset. For this exercise, the name of this new report doesn't matter. The data source should be pointed to the local, on-premises copy of the database, and the dataset should be the same as the dataset for the Azure-based report.

  2. With the new report open in Design mode, create a new data source that points to your local (on-premises) copy of the TechBio database. This new data source can use a different authentication method if you like, such as Windows Authentication (integrated security).

  3. Create a new dataset based on this new data source. On the Query page in the Dataset Properties dialog, select the data source you just created, and use the Text query type. Enter the query shown in Figure 2: it pulls from the Docs table, and you need to apply a filter so that it gives you only the documents for the associated user. You want this to be dynamic, so your filter uses a parameter that you define shortly.

    Figure 2. Dataset for the local database
  4. Select the Parameters page of the Dataset Properties dialog (see Figure 3), and notice that the parameter was added for you when you used it in the query on the Query page. It's nice to see that SSRS automatically picks up this information.

    Figure 3. Parameters page
  5. Your next step is to design your report. Back on the report, make sure the Design tab is selected, and drag a table onto the report. Again, the table has three columns by default, and you want to display five; so, add two more columns, and then center the table on the report.

  6. From the Report Data window, drag Name, Descr, Pages, Download Price, and Purchase Price columns onto the table. When you're done, the report should look like Figure 4.

    Figure 4. Completed subreport
  7. Test the report by selecting the Preview tab. The report prompts you for an AuthorId value: type in a valid value (111 or 113 should work). The report should display the appropriate data for the id you entered.

2.1. Adding the Subreport to the Main Report

Now that you're confident that your subreport works, let's wire it up to the main report:

  1. With the first report open (the Documents report), there are two ways you can add a subreport: you can either drag the report you've designated as a subreport from Solution Explorer onto the parent report, which automatically sets the appropriate properties of the subreport; or you can drag a SubReport control from the Toolbox onto the parent report and manually set the properties. How you choose to do it isn't important, as long as the appropriate properties are set; you access them by right-clicking the subreport and selecting Properties. In the Subreport Properties dialog, make sure the correct report is selected as the subreport.

  2. Select the Parameters page, and add the parameter that is being passed from the parent report to the subreport—in this case, AuthorId.

  3. You need to make a change to the parent report so your data is displayed correctly. Right now, the table lists all of the users. If you kept it that way, the report would list all the users and then list all the documents. Instead, you want it to list the users and associated documents, grouped by user. To do this, delete the table on the parent report and, from the Report Data window, drag the Name, Intro, and Title fields from the dataset onto the report, as shown in Figure 5. Now, when you run the report, it lists a user and that user's documents, as shown in Figure 6.

    Figure 5. Modified master report
    Figure 6. Finished report
Other  
  •  Reporting Services with SQL Azure : Creating the Report Design
  •  SQL Server 2008 : Explaining Advanced Query Techniques - Applying Ranking Functions (part 2) - Using RANK, DENSE_RANK and NTILE
  •  SQL Server 2008 : Explaining Advanced Query Techniques - Applying Ranking Functions (part 1) - Using ROW_NUMBER
  •  SQL Server 2008 : Demystifying Data Types - Computed Columns
  •  Programming Microsoft SQL Server 2005: Overview of SQL CLR - Visual Studio/SQL Server Integration
  •  Programming Microsoft SQL Server 2005: DDL Triggers and Notifications
  •  Programming Microsoft SQL Server 2005: Enabling CLR Integration
  •  Reporting Services with SQL Azure : Creating the SQL Azure Data Source
  •  Reporting Services with SQL Azure : Starting a SQL Azure–Based Report
  •  SQL Server 2008 : Service Broker - Message Types
  •  
    Video
    Top 10
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    The latest Audi TT : New angles for TT
    Era of million-dollar luxury cars
    Game Review : Hearthstone - Blackrock Mountain
    Game Review : Battlefield Hardline
    Google Chromecast
    Keyboards for Apple iPad Air 2 (part 3) - Logitech Ultrathin Keyboard Cover for iPad Air 2
    Keyboards for Apple iPad Air 2 (part 2) - Zagg Slim Book for iPad Air 2
    Keyboards for Apple iPad Air 2 (part 1) - Belkin Qode Ultimate Pro Keyboard Case for iPad Air 2
    Michael Kors Designs Stylish Tech Products for Women
    REVIEW
    - First look: Apple Watch

    - 3 Tips for Maintaining Your Cell Phone Battery (part 1)

    - 3 Tips for Maintaining Your Cell Phone Battery (part 2)
    Popular Tags
    Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Exchange Server Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe Photoshop CorelDRAW X5 CorelDraw 10 windows Phone 7 windows Phone 8 Iphone