Solved

DBGrid with fields from many Tables

Posted on 1998-05-26
12
435 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 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