Solved

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

Posted on 1998-12-03
3
712 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
[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
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

Industry Leaders: 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!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

623 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