Link to home
Start Free TrialLog in
Avatar of selas
selas

asked on

problem with query

on form i have two buttons, dbgrid and dbchart

on button press:

procedure TForm1.Button1Click(Sender: TObject);
begin
Series1.YValues.ValueSource := '';
AdoQuery1.Fields.Clear;
AdoQuery1.SQL.Clear;
AdoQuery1.SQL.Add('select krupje, laikas, sum(viso) from chipsai where laikas > '+QuotedStr(DatetoStr(DateTimePicker1.Date - 1))+' group by krupje order by laikas');
AdoQuery1.Open;
AdoQuery1.FieldDefList.Update;
Series1.YValues.ValueSource := 'sum(viso)';
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Series1.YValues.ValueSource := '';
AdoQuery1.Fields.Clear;
AdoQuery1.SQL.Clear;
AdoQuery1.SQL.Add('select krupje, laikas, sum(skirtumas) from chipsai where laikas > '+QuotedStr(DatetoStr(DateTimePicker1.Date - 1))+' group by krupje order by laikas');
AdoQuery1.Open;
AdoQuery1.FieldDefList.Update;
Series1.YValues.ValueSource := 'sum(skirtumas)';
end;

if i press one button all works fine, but if i press after any button i got error:
AdoQuery1: Field '' not found.
if there is no dbgrid all works fine too
How to fix it?
Avatar of kretzschmar
kretzschmar
Flag of Germany image

does your dbgrid have persistent columns?
Avatar of selas
selas

ASKER

If look in dbgrid column editor there is no columns...
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

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
I've answered this question.
yep, geo answered this q and deserves the points