Erik N
asked on
SQL-statement..
What is wrong with the following:
Query1.SQL.Add('SELECT * FROM DETAIL WHERE ID = :PARAM');
Query1.ParamByName('PARAM' ).AsIntege r:=Table1. FieldByNam e('ID').As Integer;
Query1.Open;
I get "Cannot find Parameter: Param"
Why ?
I haven't touched the properties, except for Datasource and DataBasename..
I also tried Query1.ExecSQL, but no difference..
/Thanx !
Query1.SQL.Add('SELECT * FROM DETAIL WHERE ID = :PARAM');
Query1.ParamByName('PARAM'
Query1.Open;
I get "Cannot find Parameter: Param"
Why ?
I haven't touched the properties, except for Datasource and DataBasename..
I also tried Query1.ExecSQL, but no difference..
/Thanx !
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hmm,
seems to be ok,
maybe you should give the param another name or
do a query.prepare before assigning the param like
Query1.SQL.Add('SELECT * FROM DETAIL WHERE ID = :PARAM');
Query1.Prepare;
Query1.ParamByName('PARAM' ).AsIntege r:=Table1. FieldByNam e('ID').As Integer;
Query1.Open;
meikl
seems to be ok,
maybe you should give the param another name or
do a query.prepare before assigning the param like
Query1.SQL.Add('SELECT * FROM DETAIL WHERE ID = :PARAM');
Query1.Prepare;
Query1.ParamByName('PARAM'
Query1.Open;
meikl
Perhaps the type of ID is smallint,so you should write it as Query1.ParamByName('Param' ).AsSmalli nt:=....If it doesn't work either,You can write the statement as below:
Query1.Params[0].AsInteger (Smallint) :=...
This will work absolutely!:-)
Query1.Params[0].AsInteger
This will work absolutely!:-)
Just another option is not to use a parameter at all. If you already know which id you need, just used it in the query it self. It is faster.
Try :
Query1.sql.add('select * from Detail where id = ' + strToInt(Table1.FieldByNam e('id').as Integer))
Query1.open;
ok?
Try :
Query1.sql.add('select * from Detail where id = ' + strToInt(Table1.FieldByNam
Query1.open;
ok?
ASKER
The error was in the syntax:
SELECT * FROM DETAIL WHERE ID = : PARAM
was replaced by:
SELECT * FROM DETAIL WHERE ID = :PARAM
This seems to be a little sensitive..
Thanx, all of you !
/Erik N
SELECT * FROM DETAIL WHERE ID = : PARAM
was replaced by:
SELECT * FROM DETAIL WHERE ID = :PARAM
This seems to be a little sensitive..
Thanx, all of you !
/Erik N
Query1.SQL.Add('SELECT * FROM DETAIL WHERE ID = :PARAM');
Query1.ParamByName('PARAM'
Query1.Open;