Share via


Reduced-Code Secure Database Logon in a Web Site

Introduction

In this reduced-code Web Site tutorial, you learn how to display a report that contains information from a secure SQL Server database. To provide a secure database logon, you assign the report's DataSources property to the SQLDataSource control, which is part of the new DataSource control framework in .Net 2.0.

In this tutorial, to display a report that contains information from a secure SQL Server database, you use the new tag-based application development model to connect the key components:

  • Connect a CrystalReportViewer control to a CrystalReportSource control.

  • Connect the CrystalReportSource control to a report.

  • Connect the report's DataSources property to an SqlDataSource control.

    Note

    DataSources is viewed as a report property in the Properties window, or as a tag in HTML view (Source view).

All of this work is done without having to write code.

To begin, you add a CrystalReportViewer control to the Web Form. From Smart Tasks, you create a CrystalReportSource control, and then build a Crystal report with the embedded Crystal Reports Designer. This report logs on to a secure SQL server database. The report is referenced within the CrystalReportSource control.

Then you learn how to configure the logon to the secure SQL server database, to return the required tables that are used by the Crystal report. To start, you select the "Enable Database Logon prompt" option in Smart Tasks. When that option is selected, the exception that is thrown during a database logon failure is replaced with a prompt that requests the user to log on manually.

To configure a consistent log on to the required database, you add a SqlDataSource control, and then configure it to address the secure SQL server database and return the required tables.

Finally, you assign the DataSource property of the report to the SqlDataSource control that you have created.

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_ReducedCode_DBLogon
  • Visual Basic Web Site: VB_Web_ReducedCode_DBLogon

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

In this section: