Solved

DBGrid with fields from many Tables

Posted on 1998-05-26
12
437 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 2 51
Performance of SQL statement 37 101
how to update exe applicatio from internet ? 6 68
Need Help Delphi 2010 CheckBox1 Stored value in memo 13 57
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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 hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

867 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

23 Experts available now in Live!

Get 1:1 Help Now