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

SortFields

Declaration

property SortFields: TCrpeSortFields;

Type

TCrpeSortFields = class(TPersistent);

Description

The SortFields object contains the properties needed to set and modify the Record Sort Order for a Report. The main properties are:

The Number property contains the SortField number, which is zero-based.

The Field property contains the actual SortField string. Remember to enclose field names in braces: {company.STATE}. If you sort on a formula field, use the @ sign before the formula name: {@FORMULANAME}.

The Direction property specifies the sorting direction, either sdDescending, sdAscending, or sdDefault.

The DeleteSF property can be used to delete a SortField. Remember that when a SortField is set to be deleted, it is removed from the Report in memory, when the Report is run. To reference it again, the Report would have to be loaded again, or the SortField would have to be added back using the Add method.

The Retrieve method will load the Crystal component with the SortFields currently in the Report.

The Count method will return the number of SortFields items stored in the SortFields object.

The Item and ItemIndex properties can be used to navigate through the items in the SortFields object.

SortFields Example

The code below loops through all the SortFields, changing the sort direction to descending:

var

cnt: integer; begin

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

for cnt := 0 to (Crpe1.SortFields.Count - 1) do Crpe1.SortFields[cnt].Direction := sdDescending;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

VCL Reference

107

SortFields Properties

SortFields DeleteSF property, Page 612 SortFields Direction property, Page 612 SortFields Field property, Page 613 SortFields Item property, Page 613 SortFields ItemIndex property, Page 614 SortFields Number property, Page 615

SortFields Methods

SortFields Add method, Page 615 SortFields Clear method, Page 617 SortFields CopyFrom method, Page 618 SortFields Count method, Page 618 SortFields Create method, Page 619 SortFields Delete method, Page 619 SortFields Destroy method, Page 620 SortFields Retrieve method, Page 620 SortFields Send method, Page 621

SQL

Declaration

property SQL: TCrpeSQL;

Type

TCrpeSQL = class(TPersistent)

VCL Reference

108

Description

The SQL object is only applicable to a Report created from an ODBC Data Source or from a native SQL database connection and contains the SQL Query property and the Params object, which pertains to Stored Procedure Parameters.

The Query property contains the text of an SQL Query. The Query property can be used to update the SQL Query that will be used to print the Report, typically to add optimizations to the WHERE clause. This property is particularly useful for reports with SQL Queries that were explicitly edited in the Show SQL Query dialog box in Crystal Reports (i.e., those reports that needed database-specific selection criteria or joins). Otherwise it is usually best to continue using other properties such as Selection and let Crystal Reports build the SQL Query automatically.

The Retrieve method can be used to retrieve the SQL Query from a Report and fill the Query property. Note that before using Retrieve, the necessary LogOn information should be set via the Connect or LogOnInfo properties, otherwise the Query may be empty.

The SQL Query has the same restrictions as editing in the Show SQL Query dialog box in Crystal Reports. In particular, changes are accepted in the FROM, WHERE, and ORDER BY clauses but they are ignored in the SELECT part of the Query. The reason for this is that the SELECT is determined by the database fields that are placed on the Report, and there is no way to remove or place new fields at runtime.

SQL Example

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

{Set the Connect before attempting to retrieve the Query} Crpe1.Connect.Retrieve;

Crpe1.Connect.Password := 'Aesop'; {Retrieve the Query} Crpe1.SQL.Retrieve;

{Edit the WHERE clause, assuming in this case that it is line 5} Crpe1.SQL.Query[4] := 'WHERE DEPT."LOC" = '''BOSTON'''';

Crpe1.Execute;

SQL Properties

SQL Expressions property, Page 622

Properties

SQL Expressions Expression property, Page 623

SQL Expressions Item property, Page 623

SQL Expressions ItemIndex property, Page 624

SQL Expressions Name property, Page 625

Methods

SQL Expressions Add method, Page 626

SQL Expressions Check method, Page 626

VCL Reference

109

SQL Expressions Clear method, Page 627

SQL Expressions CopyFrom method, Page 628

SQL Expressions Count method, Page 628

SQL Expressions Delete method, Page 629

SQL Expressions Destroy method, Page 630

SQL Expressions IndexOf method, Page 630

SQL Expressions Retrieve method, Page 631

SQL Expressions Send method, Page 632 SQL Params property, Page 632

Properties

SQL Params AsBoolean property, Page 634

SQL Params AsDate property, Page 634

SQL Params AsDateTime property, Page 635

SQL Params AsFloat property, Page 635

SQL Params AsInteger property, Page 636

SQL Params Item property, Page 636

SQL Params ItemIndex property, Page 637

SQL Params Name property, Page 638

SQL Params ParamType property, Page 639

SQL Params Value property, Page 640

Methods

SQL Params Add method, Page 641

SQL Params Clear method, Page 641

SQL Params CopyFrom method, Page 642

SQL Params Count method, Page 643

SQL Params Create method, Page 643

SQL Params Delete method, Page 643

SQL Params Destroy method, Page 644

SQL Params Retrieve method, Page 644

SQL Params Send method, Page 645

SQL Query property, Page 646

VCL Reference

110

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