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

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

end; Crpe1.Execute;

end;

LogOnInfo Table property

Declaration

property Table: TCrLogOnInfoTable;

Type

TCrLogOnInfoTable = integer;

Description

The Table property contains the number of the Table in the LogOnInfo item. It uses a zero-based numbering scheme, so the first Table in a Report is number 0. The Table property is the key lookup property for the LogOnInfo object and therefore cannot be changed by direct assignment. For example:

Crpe1.LogOnInfo.Table := 2;

will cause the LogOnInfo object to look up and move to the item with a Table value of 2 (if the Retrieve method was used to fill LogOnInfo, this would normally be the 3rd item). It will not overwrite the current Table property with a new Table number.

Example

This example illustrates the use of the Table property. Since the Retrieve method is used, we can be sure that the first item has a Table number of zero, the second item has a Table number of one, etc.:

var

cnt: integer; begin

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

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

{Set LogOnInfo to a specific item} Crpe1.LogOnInfo.Table := cnt;

{Set the other properties for that item} Crpe1.LogOnInfo.ServerName := 'Enterprise';

VCL Reference

403

Crpe1.LogOnInfo.UserID := 'Kirk'; Crpe1.LogOnInfo.Password := 'captain'; Crpe1.LogOnInfo.DatabaseName := 'stats';

end; Crpe1.Execute;

end;

LogOnInfo TableType property

Declaration

property TableType: TCrTableType;

Type

TCrTableType = (ttUnknown, ttStandard, ttSQL);

Description

TableType 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 DLLName, and DescriptiveName properties also provide more details that describe the Table.

TableType will be one of the following:

Table Type

Description

 

 

 

 

ttSQL

The Table is an SQL-type table, or a Table being accessed via ODBC.

 

 

ttStandard

The Table is a PC-Type database (dBase, FoxPro, Access, Paradox,

 

etc.) using native database connections, for example, not via ODBC).

ttUnknown

The TableType could not be identified.

 

 

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;

VCL Reference

404

LogOnInfo UserID property

Declaration

property UserID: string;

Description

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

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 Methods

LogOnInfo Add method

Declaration

procedure Add(TableNumber: TCrLogOnInfoTable);

Type

TCrLogOnInfoTable = integer;

VCL Reference

405

Description

The Add method adds an item to the LogOnInfo object and sets the LogOnInfo internal index to that item. It requires a Table number as a parameter, which should be a number corresponding to a Table in the Report. Tables are numbered starting from zero. If the Add method is used, the steps to using LogOnInfo are:

1Add an item to the LogOnInfo object (you must specify the Table number).

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

3When Execute is called, the properties will be sent to the Print Engine. Test can be used beforehand to check the connection.

NOTE: It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Table numbers are correct for the current Report.

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

406

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