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

Example

This example shows how to create a LogOnServer item manually, and fill the properties with values. Finally, the LogOn method is called:

with Crpe1.LogOnServer

do

begin

 

Add;

{Create a LogOnServer item}

DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

ServerName := 'oracleserver';

UserID := 'SCOTT';

 

Password := 'tiger';

 

DatabaseName := '';

{Not usually req'd for Oracle}

if LogOn then

ShowMessage('The LogOn ID is: ' + IntToStr(Number)) else

ShowMessage('Error Logging on to Server');

end;

LogOnServer Item property

Declaration

property Item[const nIndex: integer]: TCrpeLogOnServer;

Description

The Item property is a default array property. It is read-only, and only available at runtime. Its primary use is to provide an easy way to navigate through the various items stored in the LogOnServer object, allowing the object to be treated like an array.

Item is a default property, so it does not need to be specified when using the subscript: LogOnServer[2] is the same as LogOnServer.Item[2].

Item returns a reference to itself, so the LogOnServer properties can be used right after the subscript: LogOnServer[2].DatabaseName := 'MyDatabase';

Example

Since Item is a default array property, the following two blocks of code do the same thing:

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

begin

 

Add;

{Create a LogOnServer item}

DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

ServerName := 'oracleserver';

VCL Reference

415

UserID := 'SCOTT';

 

Password := 'tiger';

 

DatabaseName := '';

{Not usually req'd for Oracle}

end;

 

with Crpe1.LogOnServer do

begin

 

Add;

{Create a LogOnServer item}

DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

ServerName := 'oracleserver2';

UserID := 'WILSON';

 

Password := 'giraffe';

DatabaseName := '';

{Not usually req'd for Oracle}

end;

{Set LogOnServer object back to first item} Crpe1.LogOnServer.Item[0];

{Try Logging On}

if Crpe1.LogOnServer.LogOn then

ShowMessage('The LogOn ID is: ' + IntToStr(Number)) else

ShowMessage('Error Logging on to Server');

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

begin

 

Add;

{Create a LogOnServer item}

DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

ServerName := 'oracleserver';

UserID := 'SCOTT';

 

Password := 'tiger';

 

DatabaseName := '';

{Not usually req'd for Oracle}

end;

with Crpe1.LogOnServer do begin

Add;

{Create a LogOnServer item}

DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

ServerName := 'oracleserver2';

UserID := 'WILSON';

 

Password := 'giraffe';

DatabaseName := '';

{Not usually req'd for Oracle}

end;

{Set LogOnServer object back to first item} Crpe1.LogOnServer[0];

{Try Logging On}

if Crpe1.LogOnServer.LogOn then

ShowMessage('The LogOn ID is: ' + IntToStr(Number)) else

ShowMessage('Error Logging on to Server');

VCL Reference

416

LogOnServer ItemIndex property

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current LogOnServer item number, or set the LogOnServer object to another item.

Each object in the Crystal component that can contain more than one item uses an internal Index to maintain which item it is currently looking at, similar to the ItemIndex property of a ListBox. This Index is updated whenever the Item property is used (LogOnServer[2], for example), or whenever the key property (if applicable) is assigned a new lookup value (key properties are things like Formulas.Name, or SortFields.Number which serve as look-up properties).

The easiest way to read the current Index number is to use the ItemIndex property.

Example

The following code illustrates the use of the ItemIndex property to make sure the LogOnServer object is pointing to the first LogOnServer item:

if Crpe1.LogOnServer.ItemIndex <> 0 then Crpe1.LogOnServer[0];

LogOnServer Number property

Declaration

property Number: integer;

Description

Number is a read-only property that is filled with a value when the LogOn method is called. Before the LogOn method is called, the Number property will have zero as a default value.

Each connection established via the LogOnServer's LogOn method will generate a unique LogOn number, which is stored in the Number property. Therefore, if the Number value of a LogOnServer item is greater than zero, it indicates that a connection has been established for that Server.

The IndexOf method can be used to locate a specific number within the LogOnServer object.

VCL Reference

417

Example

This example shows how to create a LogOnServer item manually, and fill the properties with values. Finally, the LogOn method is called, which puts a LogOn ID value in the Number property:

with Crpe1.LogOnServer do begin

Add; {Create a LogOnServer item}

DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver} ServerName := 'oracleserver';

UserID := 'SCOTT'; Password := 'tiger';

DatabaseName := ''; {Not usually req'd for Oracle} if LogOn then

ShowMessage('The LogOn ID is: ' + IntToStr(Number)) else

ShowMessage('Error Logging on to Server');

end;

LogOnServer Password property

Declaration

property Password: string;

Description

The Password property contains the user password required for logging on to a SQL Server. This is not stored in the Report when it is saved (and therefore will not be returned by the Retrieve method), but must be provided before running the Report.

Example

This example shows how to create a LogOnServer item manually, and fill the properties with values. Finally, the LogOn method is called:

with Crpe1.LogOnServer do

begin

 

Add;

{Create a LogOnServer item}

DLLName := 'PDSORA7.DLL'; {Crystal's Native Oracle Driver}

ServerName := 'oracleserver';

UserID := 'SCOTT';

 

Password := 'tiger';

 

DatabaseName := '';

{Not usually req'd for Oracle}

if LogOn then

 

VCL Reference

418

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