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

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

ShowMessage('Error Logging on to Server');

end;

LogOnServer ServerName property

Declaration

property ServerName: string;

Description

This property contains the name of the Server being connected to. If the Report was created using Crystal's native SQL drivers, this will be the actual Server name. If the Report was created using ODBC drivers, this will be the ODBC Data Source Name.

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 UserID property

Declaration

property UserID: string;

Description

This property contains the user name required to log on to the SQL Server.

VCL Reference

419

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 Methods

LogOnServer Add method

Declaration

procedure Add;

Description

The Add method adds an item to the LogOnServer object and sets the LogOnServer object index to that item. If the Add method is used, the steps to using LogOnServer are:

1Add an item to the LogOnServer object.

2Fill the item's properties (ServerName, Password, etc.) with values.

3Use the LogOn method to establish a connection.

NOTE: Alternatively, if a Report has been specified in the ReportName property, the Retrieve method can be used to fill the LogOnServer with LogOn information from the Report, in which case only the Password property will need to be filled in before calling the LogOn method.

VCL Reference

420

Example

The following code illustrates using the Add method to implement a LogOnServer connection:

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 Clear method

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the LogOnServer object. It will not automatically LogOff any currently connected Servers before clearing the LogOnServer information that has been stored.

Example

This line of code clears the LogOnServer properties:

Crpe1.LogOnServer.Clear;

LogOnServer CopyFrom method

Declaration

function CopyFrom(Source: TCrpeLogOnServer): boolean;

Description

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

VCL Reference

421

Example

The following example copies all the LogOnServer property values to a temporary TCrpeLogOnServer object:

var

tempLogOnServer : TCrpeLogOnServer; begin

tempLogOnServer := TCrpeLogOnServer.Create; tempLogOnServer.CopyFrom(Crpe1.LogOnServer); {...later, when finished with the temp object...} tempLogOnServer.Free;

end;

LogOnServer Count method

Declaration

function Count: integer;

Description

The Count method can be used to obtain the number of items currently in the LogOnServer object.

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.LogOnServer.Retrieve;

for cnt := 0 to (Crpe1.LogOnServer.Count - 1) do ListBox1.Items.Add(Crpe1.LogOnServer[cnt].ServerName;

end;

LogOnServer 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

422

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