Share via


Tutorial: Logging onto a Secure SQL Server Database with a Subreport

Introduction

In the previous tutorial, Tutorial: Logging onto a Secure SQL Server Database Using Integrated Security, you learned how to display a report that requires secure SQL Server Database logon, by writing code that passes logon information to the report at runtime.

In this tutorial, you learn how to meet logon requirements for the subreport.

You need to make two modifications to the project you have created in the previous tutorial:

  • You add a subreport into the original report.

    This subreport addresses the Orders table of the Northwind database. The Orders table is related to the Customers table that is used by a CustomerID foreign key in the previous tutorial.

  • You add a new method.

    The method retrieves subreports out of the main report, and then passes each subreport to the SetDBLogonForReport() helper method.

You can also complete this tutorial with classes of the CrystalReportViewer object model, although the ReportDocument object model is preferred. For more information on which object model to use, see Which Object Model Should I Use?.

To build this tutorial with the CrystalReportViewer object model, see Tutorial: Logging onto a Secure SQL Server Database.

Sample Code

This tutorial comes with Visual Basic and C# sample code that show the completed version of the project. Follow the instructions in this tutorial to create a new project or open the sample code project to work from a completed version.

The sample code is stored in folders that are categorized by language and project type. The folder names for each sample code version are as follows:

  • C# Web Site: CS_Web_RDObjMod_DBLogonSubrpt
  • C# Windows project: CS_Win_RDObjMod_DBLogonSubrpt
  • Visual Basic Web Site: VB_Web_RDObjMod_DBLogonSubrpt
  • Visual Basic Windows project: VB_Win_RDObjMod_DBLogonSubrpt

To locate the folders that contain these samples, see Tutorials' Sample Code Directory.

In this section: