Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
163
Добавлен:
11.05.2015
Размер:
4.73 Mб
Скачать

This example will apply the Connect parameters from the main Report to the first Subreport only:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.ConnectMethod := useConnect; {Retrieve the Subreports} Crpe1.Subreports.Retrieve;

{Set the Connect Parameters} Crpe1.Connect.Retrieve; Crpe1.Connect.Password := 'Agent86'; {Switch to Subreport 1} Crpe1.Subreports[1];

{Set the Connect Propagate flag for Subreport 1} Crpe1.Connect.Propagate := True;

Crpe1.Execute;

Connect Properties

Connect DatabaseName property, Page 248

Connect Password property, Page 249

Connect Propagate property, Page 250

Connect ServerName property, Page 251

Connect UserID property, Page 251

Connect Methods

Connect Clear method, Page 252

Connect CopyFrom method, Page 253

Connect Create method, Page 253

Connect Retrieve method, Page 253

Connect Send method, Page 254

Connect Test method, Page 255

ConnectMethod

Declaration

property ConnectMethod: TCrConnectMethod;

Type

TCrConnectMethod = (useConnect, useLogOnInfo);

VCL Reference

15

Description

The ConnectMethod property is used to tell the VCL which connection method will be used to set the log on information for Reports using SQL tables or ODBC datasources that require passwords. There are two classes in the VCL that can set this information: Connect and LogOnInfo. Trying to determine which one was to be used when the VCL ran a Report was not always easy, so the ConnectMethod property was created to make this more clear.

By default, ConnectMethod is set to useConnect.

NOTE: This property applies to the whole Report, including Subreports. Therefore, it is not possible, for example, to use Connect on the main Report and LogOnInfo on the Subreport. If ConnectMethod is set to useConnect, the Connect class will be used for the main Report and any Subreports. If ConnectMethod is set to useLogOnInfo, the LogOnInfo class will be used for the main Report and any Subreports.

ConnectMethod Example

This code sets the ConnectMethod to useConnect, then fills in the Connect Password property:

Crpe1.ReportName := 'C:\Company.rpt'; {Set the ConnectMethod} Crpe1.ConnectMethod := useConnect;

{Retrieve the Connect information from the Report} Crpe1.Connect.Retrieve;

{Set the Connect Password} Crpe1.Connect.Password := '007';

{Propagate the Connect property values to any Subreports} Crpe1.Connect.Propagate := True;

Crpe1.Output := toWindow; Crpe1.Execute;

This code sets the ConnectMethod to useLogOnInfo, then fills in the LogOnInfo Password property:

var

cnt : integer; begin

Crpe1.ReportName := 'c:\Company.rpt'; {Set the ConnectMethod} Crpe1.ConnectMethod := useLogOnInfo;

{Retrieve the LogOnInfo information from the Report} Crpe1.LogOnInfo.Retrieve;

{Set the LogOnInfo Password for all tables} for cnt := 0 to (Crpe1.LogOnInfo.Count - 1) do

Crpe1.LogOnInfo[cnt].Password := '007'; Crpe1.Output := toWindow;

Crpe1.Execute; end;

VCL Reference

16

DesignControls

Declaration

property DesignControls: TCrpeDesignControlsDlg;

Type

TCrpeDesignControlsDlg = class(TForm)

Description

The DesignControls property is a design time-only property. Clicking the dialog button on the Object Inspector, or running it from the component menu (right-click on the component to get the menu), will bring up a small button-bar dialog box which can be used to load, retrieve, run, and page through Reports at design time.

Report Buttons

These buttons are on the first row of the DesignControls dialog box and control the opening, closing, retrieving and running of Reports from the Delphi design time editor.

Open Report

This button brings up the Open Dialog box to choose a Report to load. It updates the ReportName property with the new choice.

Close Report

This button closes the currently open Report, and clears the ReportName property. It is equivalent to calling CloseWindow, CloseJob, and clearing ReportName in code.

VCL Reference

17

Retrieve Data

This button brings up the Retrieve Report Data dialog box:

This dialog box allows you to choose which items you would like to retrieve report data for. Any items that are checked will have their data retrieved from the Report into the VCL when the Retrieve button is clicked. From there, the data can be edited in the Object Inspector, and then the report can be previewed to see the effect of the changes.

Quick Preview

This button runs the Report to whichever destination is specified in the Output property.

Preview Report

This button runs the Report to a Preview Window. If the WindowParent property has been set to the current Form, or a Panel on the Form, the Preview Window will be attached to that Form or Panel. When the Preview Window is attached to another Form or Panel, the Window controls will be inaccessible at design-time. Therefore, the other buttons on the DesignControls dialog box can be used to page through or close the Preview Window.

Print Report

This button runs the Report to a printer. The Print dialog box will appear to allow you to choose the destination printer.

VCL Reference

18

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