simple query with params
Posted: 07.01.2006, 21:22
Hello,
I would like to start the following SQL-statement:
dmlager.zquery2.SQL.Clear;
dmlager.ZQuery2.SQL.Add('select * from "T_BUCHUNG" where "LAGERORT" = :vrLager order by :vrsort');
dmlager.ZQuery2.Params[0].AsString:=vrLager;
dmlager.zquery2.params[1].asstring:=vrsort;
dmlager.ZQuery2.Open;
but I get the following error message:
An error was found in the application program input parameters for the sql statement. The sql: select * from "T_BUCHUNG" where "LAGERORT" = ? order by ?;' . .....
vrLager has the value: for example KOLL and vrsort BUCHUNGSDATUM.
Only with the following statement I got a result:
dmlager.zquery2.SQL.Clear;
dmlager.ZQuery2.SQL.Add('select * from "T_BUCHUNG" where "LAGERORT" = ' +qoutedstr(vrLager)+' order by '+quotedstr(vrsort)+'');
//dmlager.ZQuery2.Params[0].AsString:=vrLager;
//dmlager.zquery2.params[1].asstring:=vrsort;
dmlager.ZQuery2.Open;
That's not normal, I think. What's wrong in my first statement?
Many thanks and best regards
Josef
I would like to start the following SQL-statement:
dmlager.zquery2.SQL.Clear;
dmlager.ZQuery2.SQL.Add('select * from "T_BUCHUNG" where "LAGERORT" = :vrLager order by :vrsort');
dmlager.ZQuery2.Params[0].AsString:=vrLager;
dmlager.zquery2.params[1].asstring:=vrsort;
dmlager.ZQuery2.Open;
but I get the following error message:
An error was found in the application program input parameters for the sql statement. The sql: select * from "T_BUCHUNG" where "LAGERORT" = ? order by ?;' . .....
vrLager has the value: for example KOLL and vrsort BUCHUNGSDATUM.
Only with the following statement I got a result:
dmlager.zquery2.SQL.Clear;
dmlager.ZQuery2.SQL.Add('select * from "T_BUCHUNG" where "LAGERORT" = ' +qoutedstr(vrLager)+' order by '+quotedstr(vrsort)+'');
//dmlager.ZQuery2.Params[0].AsString:=vrLager;
//dmlager.zquery2.params[1].asstring:=vrsort;
dmlager.ZQuery2.Open;
That's not normal, I think. What's wrong in my first statement?
Many thanks and best regards
Josef