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

If the Report uses one of Crystal's native SQL drivers to connect to the Table, the DescriptiveName will be something like this:

Oracle7 SQL

Microsoft SQL Server

If the Report uses an ODBC driver to connect to the Table, the DescriptiveName will be the ODBC Data Source name with "ODBC - " prefixed to it:

ODBC - OracleTest

ODBC - Interbase

Example

The following code shows how to obtain the table description information from the LogOnInfo object:

var

cnt: integer; begin

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

if Crpe1.LogOnInfo.Count > 0 then begin

Edit1.Text := Crpe1.LogOnInfo[0].TableType; Edit2.Text := Crpe1.LogOnInfo[0].DescriptiveName; Edit3.Text := Crpe1.LogOnInfo[0].DLLName;

end; end;

LogOnInfo DLLName property

Declaration

property DLLName: string;

Description

DLLName is a runtime, read-only property that contains descriptive information about the Table that the LogOnInfo item applies to. It will only have a value if the Retrieve method was used. The DescriptiveName, and TableType properties also provide more details that describe the Table.

If the Report uses one of Crystal's native SQL drivers to connect to the Table, the DLLName will be something like this:

pdsora7.dll {Oracle} pdssql.dll {MS SQL Server}

If the Report uses an ODBC driver to connect to the Table, the DLLName will be:

pdsodbc.dll

VCL Reference

399

Example

The following code shows how to obtain the table description information from the LogOnInfo object:

var

cnt: integer; begin

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

if Crpe1.LogOnInfo.Count > 0 then begin

Edit1.Text := Crpe1.LogOnInfo[0].TableType; Edit2.Text := Crpe1.LogOnInfo[0].DescriptiveName; Edit3.Text := Crpe1.LogOnInfo[0].DLLName;

end; end;

LogOnInfo Item property

Declaration

property Item[const nIndex: integer]: TCrpeLogOnInfo;

Description

The Item property is a default array property. It is read-only, and only available at runtime. It's primary use is to provide an easy way to navigate through the various items stored in the LogOnInfo 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: LogOnInfo[2] is the same as LogOnInfo.Item[2].

Item returns a reference to itself, so the LogOnInfo properties can be used right after the subscript: LogOnInfo[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'; Crpe1.LogOnInfo.Retrieve;

{Set LogOnInfo to the 3rd Table} Crpe1.LogOnInfo.Item[2];

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

{Set LogOnInfo to the 3rd Table} Crpe1.LogOnInfo[2];

VCL Reference

400

LogOnInfo ItemIndex property

Declaration

property ItemIndex: integer;

Description

ItemIndex is a Run-time only property which can be used to obtain the current LogOnInfo item number, or set the LogOnInfo 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 (LogOnInfo[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 LogOnInfo object is pointing to the first LogOnInfo item:

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

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

VCL Reference

401

Example

This example shows how to retrieve LogOn information and then set it for each item:

var

cnt: integer; begin

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

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

Crpe1.LogOnInfo[cnt].ServerName := 'Enterprise'; Crpe1.LogOnInfo[cnt].UserID := 'Kirk'; Crpe1.LogOnInfo[cnt].Password := 'captain'; Crpe1.LogOnInfo[cnt].DatabaseName := 'stats';

end; Crpe1.Execute;

end;

LogOnInfo 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 retrieve LogOn information and then set it for each item:

var

cnt: integer; begin

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

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

Crpe1.LogOnInfo[cnt].ServerName := 'Enterprise';

VCL Reference

402

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