Solved

DBGrid Question: How can I implement this?- i think it´s noob question

Posted on 2004-08-31
4
138 Views
Last Modified: 2010-04-05
Hi folks,

I have one table (table_1) which contains 4 fieds:
1) ID;
3) Product_Name;
2) Date;
4) Price.

I set a DBGrid to shows all my RECORDS related to some month (for example, August), ordering by date. So, it seems like:

==============================
ID----Product_Name---Date-----------Price
01---Product1----------01/08/2004---20.00
02---Product2----------01/08/2004---10.00
03---Product3----------01/08/2004---50.00
04---Product4----------02/08/2004---30.00
05---Product5----------02/08/2004---10.00
06---Product6----------05/08/2004---20.00
07---Product7----------07/08/2004---15.00
(...)
==============================

I need to put in another table(table_2 - 2 fields: Date and Amount)the amount of product´s price for DATE and shows it in another DBGrid. So, this second DBGrid will be something like:

==============================
Date------------Amount
01/08/2004----80.00
02/08/2004----40.00
05/08/2004----20.00
07/08/2004----15.00
(...)
==============================


How can i implement this? I am using ADO components to connect into my MS Access database.

Best regards.
0
Comment
Question by:joelsilva
  • 2
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 30 total points
ID: 11948973
use a tadoquery as dataset with a select like

select Date, sum(price) from yourtablename group by date

btw. what means noob?

meikl ;-)
0
 

Author Comment

by:joelsilva
ID: 11949147
Hi Kretzchmar... How´ve you been friend?

"Noob" means something related to NOVICEs.

Ok... You got it again. Now my first DBGrid seems like:

==============================
Date------------Price
01/08/2004----80.00
02/08/2004----40.00
05/08/2004----20.00
07/08/2004----15.00
(...)
==============================

So, the first QUESTION is done.

The second question in this TOPIC is:

How could i INSERT in a new TABLE the new information that is in my DBGrid (as i mentioned) now and shows it in another DBGrid?

Did you get it? In the first DBGrid i just see the RESULTs from a SELECT instruction. I´d like that these results be POST in another TABLE (table_2) and i´d like to see them in another DBGrid.

Thank you for now, friend.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 11949274
also this can be done easily

use again a adoquery with a statement  like

insert into yourtable2name (Date,amount) select Date, sum(price) from yourtable1name group by date

use the execsql method for this statement

hope i understand this q correct

meikl ;-)

0
 

Author Comment

by:joelsilva
ID: 11949297
You got it man!!! You are a STAR!!!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

825 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