Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

problem with query

Posted on 2004-10-29
8
Medium Priority
?
255 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
  • 2
  • 2
5 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

572 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