Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
2.11 Mб

Passing the Recordset to the Report Designer Component

The Recordset object gets passed to the Report Designer Component through the SetDataSource method. Using the Recordset object from the example above, and assuming your report object is named Report, the following demonstrates how to assign a new data source at runtime:

Report.Database.SetDataSource rs

For more complete information, see Setting a new data source for the report.

Report Templates

If a Crystal Report file already exists that closely resembles the report you want to create, and it connects to the same or similar data and displays the data in a desirable fashion, you can use the existing report file as a report template. When you select the existing report, a copy of the report is created and set up as the basis of your new report in the Report Designer Component. The original report file is never changed.

To use a report template:

1Begin by adding the Report Designer Component to your Visual Basic project (see Adding the Report Designer Component to a Project).

2When the Report Gallery appears, click Import Report. The Open dialog box appears.

3Use the Open dialog box to locate and select an existing Crystal Report file. These files have .rpt extensions.

4Click Open. The Crystal Report Expert dialog box appears.

5Indicate whether or not you want a form containing the Crystal Smart Viewer added to your report, and, if so, whether or not this form should be the start-up form for your application.

6Click OK. An instance of the Report Designer Component appears in your project. The designer contains a new report design based on the report file you selected.

The data source accessed by the new report is identical to the data source used by the original report file. The following procedure describes how to change the location of the data source. Keep in mind, though, the structure of the new data source must match the original data source. For instance, relational databases must have identical tables and fields.

1In the Field View of the Report Designer Component window, click the plus sign next to Database Fields. A list of all data connections will appear. If the report connects directly to a database, you will see a list of database tables. If the report uses a connection technology, such as ADO, you will see ado in the list.

2Right-click one of the data connections in the list and select SET LOCATION from the shortcut menu. The Set Location dialog box appears.

3In the Databases list, select the database table or other data connection that you want to change the location of, and click Set Location. A dialog box appropriate to the connection type appears. The remaining steps assume the data connection is an ADO connection.

4With the Choose SQL Table dialog box open (the dialog box that appears when setting the location of an ADO data source), click Log On Server. The Log On Server dialog box appears.

The Report Designer Component


5 Highlight Active Data (ADO) in the Server Type drop-down list, and click OK. The Select Data Source dialog box appears. Use this dialog box to select a new ADO data source. For instructions on using this dialog box, see Selecting Data.

6Click Next, and the Select Recordset dialog box appears. Specify a new recordset for your report.

7Click Finish, and the new ADO connection appears in the SQL Databases list box of the Choose SQL Table dialog box.

8Highlight the new ADO connection, and click OK. The new data source is reflected in the Set Location dialog box.

9Click Done, and the report in the Report Designer Component window is updated.

ODBC, SQL, and PC data sources

Local and remote data sources not accessed through an object model (such as ADO or DAO) are available to the Report Designer Component if you have installed the full Seagate Crystal Reports product. The Report Designer Component can use the same database drivers that are available through Crystal Reports. This includes ODBC data sources, SQL server database systems, NT event logs, and Web server logs for Microsoft and Netscape web servers.

When connecting to an ODBC, SQL, or PC data source, the Report Designer Component provides an interface much like the Seagate Crystal Reports interface. If you click the Custom button on the Data Tab of the Create Report Expert, the Log On Server dialog box appears, providing access to ODBC data sources and SQL server database systems. If you then click the Database File button, the Choose Database File dialog box appears. Use this dialog to open xBase, Paradox, Btrieve, or Microsoft Access databases.

Connecting to an ODBC or SQL data source

The following tutorial shows how to connect to an ODBC or SQL data source while designing a report in the Report Designer Component. The tutorial begins from the Data Tab of the Create Report Expert. You could also begin by selecting the Add Database to Report command from a shortcut menu that appears when you right-click inside the Design window of the Report Designer Component.

1On the Data Tab of the Create Report Expert, click Custom. The Log On Server dialog box appears.

2If your data exists in a standard PC or ISAM database such as Microsoft Access, Borland dBASE, Btrieve, or Microsoft FoxPro, see the section below titled PC Databases. If your data is in a SQL or ODBC data source, continue with the next step.

3Use the Server Type list box in the Log On Server dialog box to select the type of data source you will use in your report. For example, to connect to the Xtreme sample data ODBC data source, select ODBC - Xtreme sample data.

4Click OK. If the SQL server or ODBC data source requires log on information, a dialog box will prompt you for the correct information. Log on to the data source as you normally do to access the data. The Choose SQL Table dialog box appears.

5Use the SQL Tables list in the Choose SQL Table dialog box to select tables from the data source to use in your

The Report Designer Component


Соседние файлы в папке crystal