Solved

How to show Master Detail fields in a single row in DBGrid

Posted on 1998-12-03
3
673 Views
Last Modified: 2010-04-04
Does anybody can show me an example
how I can show a master detail tables'
fields in one single row in DBGrid
using TTable component? They have one
to one relationship. I can't use the
TQuery component, because I have my
reason's.

Thanks.
0
Comment
Question by:davichoi
3 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1349176
heh? use datasource... or what is your problem?


0
 

Expert Comment

by:elkiors
ID: 1349177
Like zif says, add a datasource for each of your table components. Next, in the DETAIL table component set the MASTERSOURCE property to the datasource of your MASTER table.

You will also need to add the linking field to MASTERFIELDS property and the corresponding Index to INDEXNAME both of which are in the Detail table component.

Warning, if the indexname is not an index on the linking field then the tables will not behave as a master/detail relationship

Darren
0
 

Accepted Solution

by:
forns earned 40 total points
ID: 1349178
hey, davichoi!
You need 2 TDataSources and 2 TTables not connected.
Take the fitst TTable and click on "Fields Editor..." it it's context menú. Click on "Add fields..." in the Fields Editor context menú. Add all the fields available. Right click on "New field..." in the Fields Editor context menú. Ok, what you've got to do now is adding fields assigning them a name and data type.
You can see a radio group named "Field type", choose "Lookup" and the "Lookup definition" radio group is now enabled. Now you've got to link the table your editing with the second table through their common fields and choose the fields of the second table you whant to see.
For example:
You've got a table like this [ID, Description, Size] for something and another table like [ID, price] for somethin's price, ok? If you whant to see the price in the DBGrid connected to the first Table, create a new field in the first table with this parameters:
Name: fldPrice
Component: (don't care)
Type: Integer (for example)
Size: (don't care)
Field type: lookup
Key fields: ID
Dataset: Table2
Lookup Keys: ID
Result field: price

And that's all. I hope it helps.
Anyway, it the natural way do define that 2 tables would be in just one with both's fields.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 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