Solved

DBGrid with fields from many Tables

Posted on 1998-05-26
12
439 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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 100 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

813 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

10 Experts available now in Live!

Get 1:1 Help Now