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

SessionInfo Properties

SessionInfo DBPassword property

Declaration

property DBPassword: string;

Description

The DBPassword property specifies the Database Password for an MS Access table that has Database-Level security.

Example

The code example below shows how to retrieve the SessionInfo, and then loop through the items to set the UserID and UserPassword before running the Report:

var

cnt: integer; begin

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

for cnt := 0 to (Crpe1.SessionInfo.Count - 1) do Crpe1.SessionInfo[cnt].DBPassword := '007';

Crpe1.Output := toWindow; Crpe1.Execute;

end;

The next example does the same as the above, but uses the Propagate property to eliminate the need for a code loop to pass set the information for each table:

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

Crpe1.SessionInfo.Retrieve;

Crpe1.SessionInfo[0].DBPassword := '007';

Crpe1.SessionInfo.Propagate := True;

Crpe1.Output := toWindow;

Crpe1.Execute;

SessionInfo Handle property

Declaration

property Handle: LongInt;

VCL Reference

602

Description

The Handle property specifies the handle to the MS Access Session, and can be used instead of passing information to the UserID and UserPassword properties. If the Handle value is 0, the Crystal Report Engine uses the UserID and UserPassword settings. In all other cases it uses the Handle value.

SessionInfo Item property

Declaration

property Item[const nIndex: integer]: TCrpeSessionInfo;

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 SessionInfo 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: SessionInfo[2] is the same as SessionInfo.Item[2].

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

Example

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

Crpe1.ReportName := 'MyReport.rpt'; Crpe1.SessionInfo.Retrieve;

{Set SessionInfo object to the 3rd item} Crpe1.SessionInfo.Item[2];

Crpe1.ReportName := 'MyReport.rpt'; Crpe1.SessionInfo.Retrieve;

{Set SessionInfo object to the 3rd item} Crpe1.SessionInfo[2];

SessionInfo ItemIndex property

Declaration

property ItemIndex: integer;

VCL Reference

603

Description

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

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

SessionInfo Propagate property

Declaration

property Propagate: boolean;

Description

The Propagate property takes the SessionInfo values applied to the first SessionInfo item (which usually points to the first Table in a Report), and applies them to all the other SessionInfo items (or Tables) in the Report.

Propagate only applies to the current Report.

When setting Propagate for a Subreport, the other Tables in the Subreport will get their SessionInfo settings from the first Table of that Subreport.

Example

The code example below shows how to retrieve the SessionInfo, set the first item's UserID and UserPassword, then set the Propagate property to make these values apply to all other items for that Report (but not for Subreports, which must be set separately):

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

Crpe1.SessionInfo.Retrieve;

Crpe1.SessionInfo[0].UserID := 'Bond';

Crpe1.SessionInfo[0].UserPassword := '007';

Crpe1.SessionInfo.Propagate := True;

Crpe1.Output := toWindow;

Crpe1.Execute;

VCL Reference

604

SessionInfo Table property

Declaration

property Table: TCrSessionInfoTable;

Description

The Table property specifies the Table number of a SessionInfo item. It's primary use is as a look-up property to point the SessionInfo object to the item with the Table number specified. The default array property, Item, however, provides an easier way to navigate through the object.

If the Retrieve method is used, the SessionInfo information is retrieved from the Report, and the Table number of each SessionInfo item is automatically filled with values from the Report. In this case, the Table number and the Item number are usually the same, i.e. Table := 0 will point to the same item as SessionInfo[0].

Example

The code example below shows how to retrieve the SessionInfo, and then loop through the items to set the UserID and UserPassword before running the Report:

var

cnt: integer; begin

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

{Set SessionInfo to item with Table number 0} Crpe1.SessionInfo.Table := 0; Crpe1.SessionInfo.UserID := 'Bond'; Crpe1.SessionInfo.UserPassword := '007'; Crpe1.SessionInfo.Propagate := True; Crpe1.Output := toWindow;

Crpe1.Execute; end;

SessionInfo UserID property

Declaration

property UserID: string;

Description

The UserID property specifies the User ID for an MS Access table that has User-Level security.

VCL Reference

605

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