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

LogOnInfo Clear method

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the LogOnInfo object. It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear method is only applied to the LogOnInfo object of the current Report/Subreport specified in the Subreports object. Therefore, to clear all the LogOnInfo of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear method:

for cnt := 0 to (Crpe1.Subreports.Count - 1) do begin

Crpe1.Subreports[cnt];

Crpe1.LogOnInfo.Clear; end;

Example

This code clears the LogOnInfo properties for the main Report (assuming the default state of Subreports[0]):

Crpe1.LogOnInfo.Clear;

This code clears the LogOnInfo properties for the second Subreport:

Crpe1.Subreports[2];

Crpe1.LogOnInfo.Clear;

LogOnInfo CopyFrom method

Declaration

function CopyFrom(Source: TCrpeLogOnInfo): boolean;

Description

The CopyFrom method copies the LogOnInfo property values from another TCrpeLogOnInfo object. It is similar to Delphi's Assign method. It is useful for transferring or temporary storage of values.

VCL Reference

407

Example

The following example copies all the LogOnInfo property values to a temporary TCrpeLogOnInfo object:

var

tempLogOnInfo : TCrpeLogOnInfo; begin

tempLogOnInfo := TCrpeLogOnInfo.Create; tempLogOnInfo.CopyFrom(Crpe1.LogOnInfo); {...later, when finished with the temp object...} tempLogOnInfo.Free;

end;

LogOnInfo Count method

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the LogOnInfo object. It is handy for setting up loops to make similar changes to each item.

Example

The Count method is useful for looping constructions. You would normally want to call Retrieve first:

var

cnt: integer; begin

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

for cnt := 0 to (Crpe1.LogOnInfo.Count - 1) do Crpe1.LogOnInfo[cnt].Password := 'mytrickypassword';

end;

LogOnInfo Create method

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component and does not need to be called in code.

VCL Reference

408

LogOnInfo Delete method

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to remove an item from the LogOnInfo object. The "nIndex" parameter represents the number of the item in the LogOnInfo object.

Example

The following code illustrates the use of the Add and Delete methods to run a Report twice, each time with different LogOn information (it is assumed in the example that there is only one table in the Report):

Crpe1.ReportName := 'C:\Company.rpt'; with Crpe1.LogOnInfo do

begin

 

Add(0);

{Add a LogOnInfo item, first Table}

ServerName := 'oracleserver';

UserID := 'SCOTT';

 

Password := 'tiger';

 

DatabaseName := '';

{Not usually req'd for Oracle}

end;

 

Crpe1.Execute;

 

while not Crpe1.PrintEnded do Application.ProcessMessages;

Crpe1.LogOnInfo.Delete(0); with Crpe1.LogOnInfo do

begin

 

Add(0);

{Add a LogOnInfo item, first Table}

ServerName := 'oracleserver2';

UserID := 'JACOB';

 

Password := 'zebra';

 

DatabaseName := '';

{Not usually req'd for Oracle}

end;

 

{Make sure the data is not saved from the first Execute} Crpe1.DiscardSavedData := True;

Crpe1.Execute;

VCL Reference

409

LogOnInfo Destroy method

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

NOTE: The TCrpe component is responsible for creating and freeing all of the sub-classes that belong to it. The only time you would want to be concerned with doing this is if you are creating a temporary object to store data from the TCrpe using the CopyFrom method that is available from the sub-class or the CopyFrom method that is available from the main TCrpe class.

LogOnInfo PromptForLogOn property

Declaration

property PromptForLogOn: boolean;

Description

The PromptForLogOn property determines whether the VCL will create a LogOn dialog box to obtain the log on parameters required to run a Report based on SQL tables or ODBC datasources. If PromptForLogOn is set to True, and LogOnInfo.Send, or Crpe1.Execute is called, the VCL will present a LogOn dialog that looks like this:

The Connections listbox on the dialog contains a list of all unique connections required in the Report (including Subreports). The other edit fields (ServerName, UserID, Password, and DatabaseName) hold the required log on information. These can be edited. If the OK button is pressed, the log on information from the edit fields is applied to the various tables in the Report, and the Report is run. If the Cancel button is pressed, the execution of the Report stops.

VCL Reference

410

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