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

LogOnServer Delete method

Declaration

procedure Delete(nIndex: integer);

Description

The Delete method can be used to delete an item from the LogOnServer object. Note that Delete will not check to see if there is still a connection opened by that item. Therefore, LogOff should be called first, if required.

Example

The following code creates an item in the LogOnServer object, attempts a connection, logs off the connection and deletes the item:

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 not LogOn then

ShowMessage('Error Logging on Server') else

begin

if not LogOff then

ShowMessage('Error Logging off Server');

end; Crpe1.LogOnServer.Delete(Crpe1.LogOnServer.ItemIndex);

end;

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

VCL Reference

423

LogOnServer IndexOf method

Declaration

function IndexOf(LogNumber: integer): integer;

Description

The IndexOf method takes a LogOn number as a parameter and returns the numeric position of the LogOnServer item (in the LogOnServer object) that matches the LogOn number. It can be used to locate a LogOnServer item that is to be logged off.

Example

This example shows how to use the IndexOf method to locate an item in the LogOnServer object based on its LogOn number value:

procedure LogOffByNumber(Num: integer); begin

Num := Crpe1.LogOnServer.IndexOf(Num);

if not Crpe1.LogOnServer[Num].LogOff then ShowMessage('LogOff failed');

end;

LogOnServer LogOff method

Declaration

function LogOff: boolean;

Description

The LogOff method is used to terminate the connection to a Server that was logged onto using the LogOn method. Returns True if the LogOff succeeded and False if the LogOff attempt failed.

NOTE: LogOff will not normally be successful unless the Report that uses the connection is first closed, by either changing the ReportName, or using the component's CloseJob method.

VCL Reference

424

Example

This example shows how to use the IndexOf method to locate an item in the LogOnServer object based on its LogOn number value, and then LogOff that item:

procedure LogOffByNumber(Num: integer); begin

Num := Crpe1.LogOnServer.IndexOf(Num);

if not Crpe1.LogOnServer[Num].LogOff then ShowMessage('LogOff failed');

end;

LogOnServer LogOn method

Declaration

function LogOn: boolean;

Description

The LogOn method is used to create a connection to a SQL Server. Before LogOn can be called, the following steps should be followed:

1Add an item to the LogOnServer object, or use the Retrieve method.

2Fill the item's properties (ServerName, Password, etc.) with relevant values (if Retrieve was used, only the Password needs to be specified).

3Use the LogOn method to establish a connection.

If the LogOn was successful, a unique ID number will be stored in the Number property. LogOn returns True if the LogOn attempt succeeded.

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;

VCL Reference

425

LogOnServer Retrieve method

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the LogOnServer information from the Report. Unlike most of the other methods for LogOnServer, in order for the Retrieve call to work there must be a Report specified in the ReportName property.

Retrieve will actually create one LogOnServer item for each unique set of LogOn information it finds in the Report (it will also scan Subreport Tables). For example if there are two Tables in the Report going to two different Servers, then Retrieve will add two items to the LogOnServer object.

Be aware that calling Retrieve will clear the LogOnServer object of any previous information.

It is not necessary to retrieve Subreports first. If they have not yet been retrieved, LogOnServer.Retrieve will automatically retrieve them.

If LogOn information was not found, the call returns False.

Example

The following code illustrates the use of the Retrieve method to obtain unique LogOnServer information from all the Tables in the Report and any Subreports. It is not necessary to retrieve Subreports first, since LogOnServer will do this automatically if it has not been done yet:

var

cnt: integer; begin

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

{Put the ServerNames in a ListBox}

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

end;

Margins Properties

Margins Bottom property

Declaration

property Bottom: TCrMarginTwips;

VCL Reference

426

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