C++ Builder & UniDAC (Param, ExecSQL)

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
asc
Posts: 13
Joined: Wed 03 Feb 2010 10:32
Location: Germany, Siegen (NRW)

C++ Builder & UniDAC (Param, ExecSQL)

Post by asc » Wed 10 Mar 2010 10:17

Does someone have an example of me, how i set the params in an ExecSQL or ExecSQLEx instruction?

This code doesnt work:

Code: Select all

String value = "Test";
Variant params = VarArrayCreate(OPENARRAY(int,(0,2)), varVariant);
params.PutElement("pValue", 0);
params.PutElement(value , 1);
uniConnection->ExecSQL(
    "INSERT INTO table1 "
    "( Value ) "
    "VALUES "
    "( :pValue ) ",
    &params, 2);

Falcon
Devart Team
Posts: 19
Joined: Tue 02 Feb 2010 10:40

Post by Falcon » Thu 11 Mar 2010 14:29

1. Use array creation/initialization code like this:

Code: Select all

Variant* params = new Variant[2];
	params[0] = 1;
	params[1] = 7;
	UniConnection->ExecSQL("INSERT INTO Table (Id, MasterId) VALUES (:pId, :pMasterId)", params, 2);
2. Verify that the number of array elements corresponds to the actual number of parameters in SQL Query.

Post Reply