TDAParam - Dynamic Query

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
owsion
Posts: 4
Joined: Mon 17 Oct 2005 09:39

TDAParam - Dynamic Query

Post by owsion » Thu 27 Oct 2005 07:30

Hello,

I've to build dynamic queries (ie not defined with the designer).

Do you have any example?

By my side I have an exception by execution:
EAssertionFailed, AssertionFailure
\MyDac\Source\MySqlStmt.pas, line436


Here an example of my definition:

Query_Current_User := TMyQuery.Create(Owner);
with Query_Current_User do
begin
Connection := Orasession_aktiv;
SQL.Text := 'SELECT'+
' *'+
' FROM'+
' DFATAI.USER_TAI_V'+
' WHERE' +
' DFATAI.USER_TAI_V.USER_ID = :USER_ID';
UniDirectional := True;
params.CreateParam(ftUnknown,'USER_ID',ptUnknown);
end;


And the call which fails:

with DataModule_Main.Query_Current_User do
begin
ParamByName('USER_ID').AsString := str;
Active := false;
Prepare;
====> Active := true;


The same if I set the FieldType and the ParamType


THx for your help

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 31 Oct 2005 15:08

> params.CreateParam(ftUnknown,'USER_ID',ptUnknown);

In MyDAC, parameters are created automatically. To avoid the problem just comment this line.

owsion
Posts: 4
Joined: Mon 17 Oct 2005 09:39

Post by owsion » Mon 31 Oct 2005 15:25

Thanks Ikar,

you're right

Post Reply