IDalCommandParam.DataType

Syntax

DataType: DbDataType;

Description

The DataType property determines a data type of SQL query parameter.

Example

Executing the example requires that the repository contains a database with the BD identifier. This database contains a table named Table_1 that contains the Field1 and Field2 fields.

Add links to the Dal, Db, and Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    DB: IDatabaseInstance;
    Com: IDalCommand;
    Params: IDalCommandParams;
Begin
    MB := MetabaseClass.Active;
    DB := MB.ItemById("BD").Open(NullAs IDatabaseInstance;
    Com := DB.Connection.CreateCommand("Insert Into Table_1 (Field1,Field2) Values(:1,:2)");
    Com.Parse;
    Params := Com.Params;
    Params.Item(0).DataType := DbDataType.Integer;
    Params.Item(1).DataType := DbDataType.String;
    Params.Item(1).Size := 50;
    Com.MaxParamsRows := 4;
    //First value
    Params.Item(0).Value := 1;
    Params.Item(1).Value := "First";
    Com.NextParamsRow;
    //Second value
    Params.Item(0).Value := 2;
    Params.Item(1).Value := "Second";
    Com.NextParamsRow;
    //Third value
    Params.Item(0).Value := 3;
    Params.Item(1).Value := "Third";
    Com.NextParamsRow;
    //Forth value
    Params.Item(0).Value := 4;
    Params.Item(1).Value := "Fourth";
    Com.Execute;
    Com.Close;
End Sub UserProc;

After executing the example the connection to the BD database is established, the SQL query that inserts the records to the Table_1 table is executed. The fields values are represented as the collection of parameters values of the command that is executed at the database server.

See also:

IDalCommandParam