IUiParams.CreateParam

Syntax

CreateParam(FieldType: DbDataType; ParamName: String): IUiParam;

Parameters

FieldType - parameter that determines a type of the parameter under creation.

ParamName - name of the parameter under creation. This name must match name of the parameter used in the SQL query.

Description

The CreateParam method creates the parameter, which type and name are passed by the FieldType and the ParamName input parameters.

Example

Executing the example requires a form with the Button1 button, the UiQuery component named UiQuery1. The repository contains the BD database. This database stores the Tablica_1 table data. The table contains the Id field that contains integer values.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);

Var

MB: IMetabase;

Params: IUiParams;

Param: IUiParam;

Begin

MB := MetabaseClass.Active;

Params := UiQuery1.Params;

UiQuery1.Database := MB.ItemById("BD").Bind As IDatabase;

UiQuery1.SQL.AsString := "Select * From Tablica_1 Where (ID>=:Item) And (ID<=:Item1)";

Param := Params.CreateParam(DbDataType.Integer, "Item");

Param.Value := 10;

Param := Params.CreateParam(DbDataType.Integer, "Item1");

Param.Value := 20;

UiQuery1.Active := True;

End Sub Button1OnClick;

 

After executing the example, clicking the button sets the UiQuery1 component parameters. On opening a data source, on executing the query, records of the Id field, which values fall into the [10;20] range.

See also:

IUiParams