Show contents 

ExtCtrls > ExtCtrls Assembly Interfaces > IUiParams > IUiParams.CreateParam

IUiParams.CreateParam

Syntax

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

Parameters

FieldType. Parameter that determines a type of created parameter.

ParamName. Name of created parameter. 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, a button named Button1 on the form and the UiQuery component named UiQuery1. The repository contains the BD database. This database stores the TABLE 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 are in the [10;20] range.

See also:

IUiParams