Ver Mensaje Individual
  #6  
Antiguo 21-11-2005
Epachsoft Epachsoft is offline
Miembro
 
Registrado: abr 2005
Posts: 167
Reputación: 20
Epachsoft Va por buen camino
Hola,

Usualmente yo lo hago asi. Disculpen la sitnaxis va a pura memoria.

Var
S : TStringList;

begin
S:= TStringList.Create;
try
S.Clear;
s.add('select * from albaranes');
s.add('from albaranes');
s.add('where year(fecha)=:year and month(fecha)=:month');
adodataset.CommandText:=S.Text;
adodataset.Parameters.ParseSQL(S.text,true);
adodataset.Parameters.ParamByName('year').value:=2005;
adodataset.parameters.parambyname('month').value:=11;
adodataset.Open;
try
// haga algo
finally
adodataset.close;
end;
finally
S.Free;
end;

Si esta usando un adoquery, yo creo que aun agregando el texto al SQL tstring, el no detecta los parametros en runtime a menos que se llame el parsesql.

Si no va a usar parametros, es mejroq que use un Format y agregue los valores de fecha como %s.
__________________
Esteban Pacheco
A delphi programming blog

Última edición por Epachsoft fecha: 21-11-2005 a las 17:00:20.
Responder Con Cita