Solved

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

Posted on 2004-08-31
4
136 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now