Board index » delphi » why can not I use the parameter name?

why can not I use the parameter name?


2007-08-11 09:01:47 AM
delphi106
Hi all,
I have the following code and it raise an error
dmCompra.tblMasterCompras.Close;
dmCompra.tblMasterCompras.SQL.Clear;
dmCompra.tblMasterCompras.SQL.Add('Select * from Compra Where
FecCom>=:FecIni and FecCom <= :FecFin Order by FecCom');
dmCompra.tblMasterCompras.Prepared := True;
dmCompra.tblMasterCompras.Parameters.Refresh;
dmCompra.tblMasterCompras.Parameters.ParamByName('FecIni').Value
:= frm.dtpFecIni.Date;
dmCompra.tblMasterCompras.Parameters.ParamByName('FecFin').Value
:= frm.dtpFecFin.Date;
dmCompra.tblMasterCompras.Open;
When I change the Parameter name to Param1 and Param2 is solved the error,
Why can not I use the parameter name that I specified in the SQL Statement?
Thanks in advance
Alfredo Becerril
 
 

Re:why can not I use the parameter name?

Have you set the connection property to an existending connection before
you set the sql property?.
I have found the same problem when connection was not set.
Alfredo Becerril schrieb:
Quote
Hi all,

I have the following code and it raise an error

dmCompra.tblMasterCompras.Close;
dmCompra.tblMasterCompras.SQL.Clear;
dmCompra.tblMasterCompras.SQL.Add('Select * from Compra Where
FecCom>=:FecIni and FecCom <= :FecFin Order by FecCom');
dmCompra.tblMasterCompras.Prepared := True;
dmCompra.tblMasterCompras.Parameters.Refresh;
dmCompra.tblMasterCompras.Parameters.ParamByName('FecIni').Value
:= frm.dtpFecIni.Date;
dmCompra.tblMasterCompras.Parameters.ParamByName('FecFin').Value
:= frm.dtpFecFin.Date;
dmCompra.tblMasterCompras.Open;

When I change the Parameter name to Param1 and Param2 is solved the error,

Why can not I use the parameter name that I specified in the SQL Statement?

Thanks in advance

Alfredo Becerril