Link to home
Start Free TrialLog in
Avatar of selas
selas

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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;
let
> AdoQuery1.SQL.Active := .... // True or False;
to be
   AdoQuery1.Active := .... // True or False;

sorry ....