?
Solved

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

Posted on 2004-08-31
4
Medium Priority
?
144 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 120 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
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
Course of the Month13 days, 23 hours left to enroll

807 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