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

LogOnInfo

Declaration

property LogOnInfo: TCrpeLogOnInfo;

Type

TCrpeLogOnInfo = class(TPersistent)

Description

The LogOnInfo object is used to set the LogOn information for each table in the Report. It applies to Reports based on SQL tables or ODBC datasources, as does the Connect property, and LogOnServer.

The difference between LogOnInfo and Connect is that LogOnInfo allows different LogOn parameters for each table, whereas Connect takes one set of parameters and applies them to all the tables in a Report. Therefore, if a Report is designed with tables from more than one Server, LogOnInfo should be used instead of Connect.

LogOnInfo contains the basic Server information properties:

ServerName

UserID

Password

DatabaseName

As well, it contains read-only properties that display information about the Table Type and Crystal Database DLL used to access the Table:

TableType

DescriptiveName

DLLName

These properties will only have meaningful values if the Retrieve method is used to get the LogOn information from the Report. Otherwise, if the manual Add method is used, these values will contain empty strings.

The PromptForLogOn property can be used to bring up a dialog box prompting for LogOn information.

The Table property contains the Table number as defined in the Report. This number represents the order in which the Tables were added to the Report, and can be viewed by opening the Report in the Crystal Reports Designer and going to the "Database | Set Location..." menu item. The Tables appear in a list, and are numbered internally from top to bottom.

If the Retrieve method has been used, the Count method will yield the number of SQL tables in the Report, and is useful for looping constructs.

The Test method provides a useful means of testing the Table connectivity after the desired parameters have been changed. This will reveal if the LogOn information is correct or not.

NOTE: Important! In order to use the LogOnInfo properties, the Crpe1.ConnectMethod property must be set to use LogOnInfo. This setting tells the VCL's Executemethod which class to use for connecting: Connect or LogOnInfo.

VCL Reference

52

LogOnInfo Example

This example shows how to use the LogOnInfo object to supply a new UserID and Password for the SQL tables in a Report. It is assumed that the ServerName and DatabaseName will remain the same as they were when the Report was designed. Notice that the code tests each table to see if the LogOn information works:

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

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

Crpe1.LogOnInfo[cnt]; Crpe1.LogOnInfo.UserID := 'Maxwell Smart'; Crpe1.LogOnInfo.Password := 'Agent86';

if Crpe1.LogOnInfo.Test then ShowMessage('LogOn information is good')

else

ShowMessage('LogOn information is not good');

end;

LogOnInfo Properties

LogOnInfo DatabaseName property, Page 398

LogOnInfo DescriptiveName property, Page 398

LogOnInfo DLLName property, Page 399

LogOnInfo Item property, Page 400

LogOnInfo ItemIndex property, Page 401

LogOnInfo Password property, Page 401

LogOnInfo ServerName property, Page 402

LogOnInfo Table property, Page 403

LogOnInfo TableType property, Page 404

LogOnInfo UserID property, Page 405

LogOnInfo Methods

LogOnInfo Add method, Page 405

LogOnInfo Clear method, Page 407

LogOnInfo CopyFrom method, Page 407

LogOnInfo Count method, Page 408

LogOnInfo Create method, Page 408

LogOnInfo Delete method, Page 409

VCL Reference

53

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