Database Credentials

One of the nice things about the version 10 Crystal Report Viewers as opposed to previous versions is that if the report needs database credentials, it prompts the user for this information. Figures 29.6 and 29.7 show the Windows Forms and Web Forms Viewers database credential prompting.

Figure 29.6. The Windows Forms Viewer prompts for database credentials.

graphics/29fig06.jpg


Figure 29.7. The Web Forms Viewer prompts for database credentials.

graphics/29fig07.jpg


Although this is a nice feature, you will often want to suppress this and handle the database credentials themselves. The first reason to do this is to change the appearance or behavior of the database credential process. This could be as simple as customizing the look and feel of the user interface or perhaps changing the behavior in some way. For example, you could have the user prompted the first time but offer to save the credentials for later. This could be accomplished by writing the credentials to a cookie or database. The second reason for suppressing the viewers prompting would be to set the credentials transparently behind the scenes, so the user won need to enter them at all. The logic of the viewers is to determine whether credentials have been supplied through the viewer directly, and if not, to see if the corresponding report has them defined, and finally if not, to prompt the user. Therefore the solution to customizing or eliminating the database credential prompts is to simply set them before the report is viewed.

The easiest way to do this is to use the ReportDocuments SetDatabaseLogon method. This function is overloaded for several different argument types. There are really only two of them that you will use. The simplest version of SetDatabaseLogon accepts two strings: a username and password. Keep in mind that Crystal Reports stores the information required to connect to the database inside the RPT file, so unless you want to change the database, you only need to set the username and password. An example of this is shown in the following code:






Dim Report As New ReportDocument()

Report.Load("C:ReportsFinance.rpt")

Report.SetDatabaseLogon("username", "password")

Viewer.ReportSource = Report


In this case, the Viewer object could be either a Windows Forms Viewer or a Web Forms Viewer because they both have the ReportSource property.

NOTE

When using the Web Forms Viewer, keep in mind that the viewer is stateless, that is, each time the ASPX page is processed, the credentials need to be set unless you are caching the ReportDocument object somewhere.


The other version of the SetDatabaseLogon method takes four string arguments: username, password, server name, and database name. This is useful for taking reports based off a test database and pointing them to a production database. Simply pass in the server name and database name you want the report to use, like this:






Report.SetDatabaseLogon("username", "password", "SERVER01", "SalesDB")



Part I. Crystal Reports Design

Creating and Designing Basic Reports

Selecting and Grouping Data

Filtering, Sorting, and Summarizing Data

Understanding and Implementing Formulas

Implementing Parameters for Dynamic Reporting

Part II. Formatting Crystal Reports

Fundamentals of Report Formatting

Working with Report Sections

Visualizing Your Data with Charts and Maps

Custom Formatting Techniques

Part III. Advanced Crystal Reports Design

Using Cross-Tabs for Summarized Reporting

Using Record Selections and Alerts for Interactive Reporting

Using Subreports and Multi-Pass Reporting

Using Formulas and Custom Functions

Designing Effective Report Templates

Additional Data Sources for Crystal Reports

Multidimensional Reporting Against OLAP Data with Crystal Reports

Part IV. Enterprise Report Design Analytic, Web-based, and Excel Report Design

Introduction to Crystal Repository

Crystal Reports Semantic Layer Business Views

Creating Crystal Analysis Reports

Advanced Crystal Analysis Report Design

Ad-Hoc Application and Excel Plug-in for Ad-Hoc and Analytic Reporting

Part V. Web Report Distribution Using Crystal Enterprise

Introduction to Crystal Enterprise

Using Crystal Enterprise with Web Desktop

Crystal Enterprise Architecture

Planning Considerations When Deploying Crystal Enterprise

Deploying Crystal Enterprise in a Complex Network Environment

Administering and Configuring Crystal Enterprise

Part VI. Customized Report Distribution Using Crystal Reports Components

Java Reporting Components

Crystal Reports .NET Components

COM Reporting Components

Part VII. Customized Report Distribution Using Crystal Enterprise Embedded Edition

Introduction to Crystal Enterprise Embedded Edition

Crystal Enterprise Viewing Reports

Crystal Enterprise Embedded Report Modification and Creation

Part VIII. Customized Report Distribution Using Crystal Enterprise Professional

Introduction to the Crystal Enterprise Professional Object Model

Creating Enterprise Reports Applications with Crystal Enterprise Part I

Creating Enterprise Reporting Applications with Crystal Enterprise Part II

Appendix A. Using Sql Queries In Crystal Reports

Creating Enterprise Reporting Applications with Crystal Enterprise Part II



Special Edition Using Crystal Reports 10
Special Edition Using Crystal Reports 10
ISBN: 0789731134
EAN: 2147483647
Year: 2003
Pages: 341

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net