Solved

DBGrid with fields from many Tables

Posted on 1998-05-26
12
445 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi selector screen 2 97
Multiple image collision 13 108
control image tags in a string ? 12 169
TEMBEDDEDWB how can i change its user agent ? 8 106
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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