how to add all fields to query programicaly?

i'm using this query:

AdoQuery1.SQL.Clear;
AdoQuery1.SQL.Add('select krupje, laikas, skirtumas, viso from chipsai where laikas > '+QuotedStr(DatetoStr(DateTimePicker1.Date - 1))+' order by laikas');
AdoQuery1.Open;

and i want to clear old field
and to add these fields to query programicaly like in fields editor
selasAsked:
Who is Participating?
 
kretzschmarConnect With a Mentor Commented:
??
usual its done automatically after the open-method
you can force it with Dataset.FieldDef.Update;

just from head

meikl ;-)
0
 
esoftbgCommented:
AdoQuery1.SQL.Active := False;
AdoQuery1.SQL.Text := 'select krupje, laikas, skirtumas, viso from chipsai where laikas > '+QuotedStr(DatetoStr(DateTimePicker1.Date - 1))+' order by laikas';
AdoQuery1.SQL.Active := True;

//....

Using:
AdoQuery1.SQL.Text := ....;
you clear whole old content and replace with new one
0
 
esoftbgCommented:
If you have a problem with assigning the condition in the clause WHERE:
 .... WHERE LAIKAS > ' + QuotedStr(DatetoStr(DateTimePicker1.Date - 1)) ....

you may use a parameter:

AdoQuery1.SQL.Active := False;
AdoQuery1.SQL.Text := 'select krupje, laikas, skirtumas, viso from chipsai where LAIKAS > :PRM_LAIKAS order by laikas';
AdoQuery1.Parameters.ParamByName('PRM_LAIKAS').Value := TDateTime(DateTimePicker1.Date - 1);
AdoQuery1.SQL.Active := True;
0
 
esoftbgCommented:
let
> AdoQuery1.SQL.Active := .... // True or False;
to be
   AdoQuery1.Active := .... // True or False;

sorry ....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.