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

CanCloseEngine

Declaration

property CanCloseEngine: boolean;

Description

CanCloseEngine is a runtime, read-only property that determines whether or not the Crystal Reports Print Engine can be closed. Use this function before calling CloseEngine to verify that the engine is no longer processing print jobs. If the Print Engine closes while a print job is still running, an error can occur in your application or on the user's system.

NOTE: The Crystal component will automatically close the Print Engine when its Destroy method is called, or when the Form it is on is destroyed.

CanCloseEngine Example

The CanCloseEngine property can be used to determine if the Print Engine is done processing jobs. In this example the VCL is dynamically created and freed:

var

Crpe1: TCrpe; begin

Crpe1 := TCrpe.Create(Self); Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Output := toWindow; Crpe1.Execute;

while not Crpe1.CanCloseEngine do Application.ProcessMessages;

Crpe1.Free; end;

NOTE: In the example above, the CanCloseEngine will not return True until all Print Jobs are finished processing. Other properties such as IsJobFinished, PrintEnded, and Status will work on just the current Print Job, and could be used instead.

Connect

Declaration

property Connect: TCrpeConnect;

Type

TCrpeConnect = class(TPersistent)

VCL Reference

13

Description

The Connect object contains the properties that refer to the Report LogOn information required to connect to an ODBC or SQL datasource. It has the same four basic properties as LogOnInfo:

ServerName

UserID

Password

DatabaseName

Whereas LogOnInfo allows different LogOn parameters for each table, Connect takes one set of parameters and applies them to all the tables in a Report. Therefore, if a Report is designed with tables from more than one Server, LogOnInfo should be used instead of Connect. However, if the main Report uses one Server, and the Subreport uses another, then Connect can still be used, since it can apply to Subreports as well.

The Retrieve method will obtain the ServerName, UserID, and DatabaseName from the current Report, and fill the Connect properties with those values. If these values are to remain the same as when the Report was designed, all that needs to be supplied is the Password.

The Test method can be used to test the connection once the four basic properties have been filled in.

The Propagate property is designed to take the LogOn information from the main Report and use it for the Subreports as well. If Propagate is set to True for the main Report, the Connect information from the main Report will be used for all the Subreports. But if Propagate is set to True on a Subreport, then only that Subreport will use the Connect parameters set in the main Report. See the Example for an illustration of this.

NOTE: Important! In order to use the LogOnInfo properties, the Crpe1.ConnectMethod property must be set to useConnect. This setting tells the VCL's Execute method which class to use for connecting: Connect or LogOnInfo.

NOTE: When running a Report that requires the Connect properties to be set (most SQL databases), make sure that the proper files have been installed in order for the connection to succeed:

If the connection is being established via an ODBC Data Source, make sure the ODBC driver has been installed, and the Data Source has been properly configured on the computer.

If the connection is being established via Crystal's native SQL drivers, make sure the Client layer has been installed and that the Database/BIN location is in the PATH statement of the AUTOEXEC.BAT file.

Connect Example

The following code will use the Connect parameters for the main Report and apply them to all Subreports also:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.ConnectMethod := useConnect;

Crpe1.Connect.Retrieve;

Crpe1.Connect.Password := 'Agent86';

Crpe1.Connect.Propagate := True;

Crpe1.Execute;

VCL Reference

14

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