Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DBGrid with fields from many Tables

Posted on 1998-05-26
12
Medium Priority
?
472 Views
Last Modified: 2010-04-06
Is it possible to display a dbgrid with columns filled with fields from more than one Table ? And how ?
Or what component (else than  dbgrid) do you use to display such lists ?

i.e. i have a table which contains book's titles and another with writers. The two tables are indexed and 'linked' (through Apollo function: setRelation, or through Delphi MasterFields/Source)
 
I want a dbgrid with the first colums displaying the titles and the second displaying the writers.
(dynamicly during the program, pls)

JMV  
 
0
Comment
Question by:jm verdi
  • 4
  • 2
  • 2
  • +4
12 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1347928
HI JMV, what about making a query from these tables and displaying this query into the grid? Otherwise it would be very hard (implementing a dbgrid which can have to tables)
Regards, ZiF.
0
 

Author Comment

by:jm verdi
ID: 1347929
Hi Zif,

In XBase languages, when we create a 'dbedit' or a 'browse' (which are exactly the equivalent to the DBGrid) it's so simple (and so practic) to declare:
this column is: 'BookTitle' (the name of a field from Table1) and this column is 'Table2->WriterName'
.. that i simply could not imagine that it was not possible with a Delphi component !
But if you say so, than perhaps not ;-(  !

I'll take a look about displaying query into the grid.
Thanks

May be some old XBase programmers have found some solution ?

JMV





0
 
LVL 2

Expert Comment

by:kjteng
ID: 1347930
Do you think a query like the following is difficult compared to XBase approach:

SELECT a."title", b."author"
FROM "aaa.db" a, "bbb.db" b
WHERE ( a.ID= b.ID)
ORDER BY a."title"

Remember: Apart from selecting the fields to display, we are also filtering the records and changing the sort order. Further, this query can be dynamic ie change at run time.

0
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!

 
LVL 3

Expert Comment

by:d4jaj1
ID: 1347931
Zif,

What ever happend to the Super DBGrid you and Inter were making?
0
 

Author Comment

by:jm verdi
ID: 1347932
Hi kjteng,

Yes, i admit, it's very simple too to use query. But is it really dynamic?
I mean (i never used query so my question is perhaps stupid):
When i browse through databases, using a query, and one file of this database is changed (ie: someone one the network change a record: 'this book is not written by Dupond but by Durand') what happen if this change is made after i realized the query?
Other manner asked: when i do a query, is the result fixed ? Or is it a dynamic link ?
(because with XBase setRelation and DBEdit  [DBedit is not the same as in Delphi, it's a grid] each time i press the PgDwn Key, the xx next records displayed in the columns are 'fresh' )

JMVerdi




0
 
LVL 2

Expert Comment

by:kjteng
ID: 1347933
It is dynamic if you set the requestLive property of tQuery to true. (except that there are some restriction in local sql - please refer to help)

To me it is "dynamic" because I can change my query at run time without recompiling my program: either the sql programatically or load the sql from a text file.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1347934
Hi JM verdi,

If you set RequestLive to true it will only work with a query made of 1 table. If you have several tables combined to one Query and you want to have it 'live' you should work with TUpdateSQL's.

d4jaj1,

I know, the problem is, that on these things I don't have much knowledge... but now I bought a book, so maybe in the future!

Regards, Zif.
0
 

Author Comment

by:jm verdi
ID: 1347935
kjteng,

Thanks for your answer, and the remark of Zif about the refresh of only one table.
What i learned here is that this component doesn't exist in Delphi but that we can make the same thing (perhaps better) in other manner.
Now i want just wait a few days to see evntually others developpers that have an idea where such a component can be, if exist.
I know that a lot of XBase programmers have choice Delphi now, so i wonder if an old XBase developper has written something between our old Clipper TBrowse and the Delphi DBGrid.

Jean marie Verdi

0
 
LVL 1

Expert Comment

by:Marcius
ID: 1347936
Check out the InfoPower components. They have a lot of good database comps, perhaps one of them will help you out :)
0
 

Expert Comment

by:skeleton
ID: 1347937
You can try using calculated fields if you want more than one
table in dbgrid, but i don't think it will as "dynamic" as a query.

The best dbgrid for what you looking for is Top support - top dbgrid. It will allow you to dynamically add columns and
dynamically supply data to the grid.

You can download demo at
http://www.topsupport.com/html/download.html.

Hope ti helps.
0
 
LVL 2

Accepted Solution

by:
hrizal earned 400 total points
ID: 1347938
you need virtual field on master table.

for example :

 on TABLE1, go to field editor (right button on component).
 and then click again right button, select add field, select all
 and then select new field,
 fill field name and type
 select LOOKUP for field type
 define dataset to other table which you want to see in grid of table 1

 OK ? ...
0
 

Author Comment

by:jm verdi
ID: 1347939
hrizal,

Thanks, that's what i was looking for
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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

877 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