[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

problem with query

Posted on 2004-10-29
8
Medium Priority
?
250 Views
Last Modified: 2010-04-05
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?
0
Comment
Question by:selas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
8 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12442778
does your dbgrid have persistent columns?
0
 

Author Comment

by:selas
ID: 12442813
If look in dbgrid column editor there is no columns...
0
 
LVL 17

Accepted Solution

by:
geobul earned 2000 total points
ID: 12443094
You don't close the query:

procedure TForm1.Button1Click(Sender: TObject);
begin
Series1.YValues.ValueSource := '';
AdoQuery1.Close; // <-- this line
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;

and the same in the other button event.

Regards, Geo
0
 
LVL 17

Expert Comment

by:geobul
ID: 13343315
I've answered this question.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 13343388
yep, geo answered this q and deserves the points
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question