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

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

{if the SectionType is Group Header, apply the change}

if (Crpe1.AreaFormatFormulas[cnt].SectionType = 'GH') then begin

Crpe1.AreaFormatFormulas[cnt].Name := afHide; Crpe1.AreaFormatFormulas[cnt].Formula.Text := '{company.STATE} = "CA"';

end; end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

AreaFormatFormulas Send method

Declaration

function Send: boolean;

Description

The Send method sends the AreaFormatFormulas values to the Crystal Reports Print Engine. This method is called automatically when the Execute method is called, provided that SendOnExecute is set to True.

We strongly recommend that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine. If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method. This feature is mainly provided for debugging purposes.

Example

In this example, the AreaFormatFormulas settings are sent from the Crystal component to the Crystal Reports Print Engine DLL. This is normally handled automatically in the Execute method:

Crpe1.AreaFormatFormulas.Send;

Connect Properties

Connect DatabaseName property

Declaration

property DatabaseName: string;

Description

This property contains the name of the Database being connected to. Most SQL Servers require this parameter (Oracle is usually an exception to the rule).

VCL Reference

248

NOTE: With Crystal's runtime engine, it is possible to change the database name or path that an ODBC Datasource is pointing to, without having to reconfigure the Datasource manually. See CRWDC for the full explanation and examples.

When using an ODBC Datasource that goes to a PC-type database (dBase, FoxPro, Paradox, etc.), where the Datasource points to a directory, not an actual table, the DatabaseName property cannot be used to change the name of the database being used by the Report. Use the Tables object instead.

Example

The following example sets the Connect properties and tests the connection before running the Report:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Connect.ServerName := 'WBSQLServer'; Crpe1.Connect.UserID := 'Elmer Fudd'; Crpe1.Connect.Password := 'Wabbit'; Crpe1.Connect.DatabaseName := 'Company1'; if Crpe1.Connect.Test then

Crpe1.Execute else

ShowMessage('Error Connecting');

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

Example

The following example sets the Connect properties and tests the connection before running the Report:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Connect.ServerName := 'WBSQLServer'; Crpe1.Connect.UserID := 'Elmer Fudd'; Crpe1.Connect.Password := 'Wabbit'; Crpe1.Connect.DatabaseName := 'Company1'; if Crpe1.Connect.Test then

Crpe1.Execute else

ShowMessage('Error Connecting');

VCL Reference

249

Connect Propagate property

Declaration

property Propagate: boolean;

Description

The Propagate property causes the Connect information from the main Report to apply to any Subreports also. Since the Connect object is created for Subreports as well, there are two ways of using this property:

1.Propagate is set to True for the main Report - This will cause all Subreports to use the same Connect values as the main Report.

2.Propagate is set to True for a Subreport - This will cause that particular Subreport to get it's Connect information from the main Report. All other Subreports will not be affected.

Propagate is True by default.

Example

The following code will cause the Connect values to be used for any Subreports also:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Connect.ServerName := 'WBSQLServer'; Crpe1.Connect.UserID := 'Elmer Fudd'; Crpe1.Connect.Password := 'Wabbit'; Crpe1.Connect.DatabaseName := 'Company1'; Crpe1.Connect.Propagate := True;

if Crpe1.Connect.Test then Crpe1.Execute

else

ShowMessage('Error Connecting');

The following code will cause the first Subreport to get it's Connect values from the main Report:

Crpe1.ReportName := 'C:\Company.rpt'; {Retrieve Subreports} Crpe1.Subreports.Retrieve;

{Go to main Report} Crpe1.Subreports[0];

{Set the main Report Connect} Crpe1.Connect.ServerName := 'WBSQLServer'; Crpe1.Connect.UserID := 'Elmer Fudd'; Crpe1.Connect.Password := 'Wabbit'; Crpe1.Connect.DatabaseName := 'Company1'; {Go to first Subreport} Crpe1.Subreports[1];

VCL Reference

250

{Set Propagate for the Subreport Connect} Crpe1.Connect.Propagate := True;

{Go back to main Report} Crpe1.Subreports[0]; {Run the Report}

if Crpe1.Connect.Test then Crpe1.Execute

else

ShowMessage('Error Connecting');

Connect 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

The following example sets the Connect properties and tests the connection before running the Report:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Connect.ServerName := 'WBSQLServer'; Crpe1.Connect.UserID := 'Elmer Fudd'; Crpe1.Connect.Password := 'Wabbit'; Crpe1.Connect.DatabaseName := 'Company1'; if Crpe1.Connect.Test then

Crpe1.Execute else

ShowMessage('Error Connecting');

Connect UserID property

Declaration

property UserID: string;

Description

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

VCL Reference

251

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