Solved

Mutliple Datasources in DBGrid

Posted on 1998-02-28
8
313 Views
Last Modified: 2010-04-06
How can I gave multiple datasources in a single DBGrid?  I have a Master tables that has several details tables (5).  I want only certain coulmns from each detail table to appear in the grid.  How can I do this?

The solution given must allow a quick update of the DBGrid, so quering each detail table when the master record change is just too slow.

I will increase teh points if necessary.
0
Comment
Question by:d4jaj1
8 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1359905
That was also something that I wanted to accomplish, but... I think it isn't that easy. I think a new component has to be made. I don't know yet how to solve this problem.
0
 

Expert Comment

by:jpussacq
ID: 1359906
You can create a view in the Datab Base.
0
 

Expert Comment

by:bijoyn
ID: 1359907
Hi ,

Well first of all u cannot assign mulitple datasources to one DBGrid. At any point of time the grid will talk to only one datasources. U can make it talk to multiple datasources one after the other but only one at a time.

Secondly how can u show data from more than one detail table in the same grid for a master record. In each of the five detail tables that u have u must be having one to many detail records for each master records right ?. Now if u read all the detail tables  at the same time then in one row of the grid how are u going to show the multiple values coming from the detail tables ?

U need to show the one to many relationships in more than one grid ( in your case 5 separate grids ). But if u still want to do what u are doing then there is a solution for it.

Tell me if u are interested. Send me your email address and I will send u an example.

Cheers,

Bijoy
0
Independent Software Vendors: 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!

 

Expert Comment

by:bijoyn
ID: 1359908
Hi ,

Well first of all u cannot assign mulitple datasources to one DBGrid. At any point of time the grid will talk to only one datasources. U can make it talk to multiple datasources one after the other but only one at a time.

Secondly how can u show data from more than one detail table in the same grid for a master record. In each of the five detail tables that u have u must be having one to many detail records for each master records right ?. Now if u read all the detail tables  at the same time then in one row of the grid how are u going to show the multiple values coming from the detail tables ?

U need to show the one to many relationships in more than one grid ( in your case 5 separate grids ). But if u still want to do what u are doing then there is a solution for it.

Tell me if u are interested. Send me your email address and I will send u an example.

Cheers,

Bijoy
0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1359909
I was thinking of something like this.

Master Record  (Text boxes)
============================
Cust Name, Address, etc.

Detail Records (1 DB Grid)
===========================
  Detail Tables - Software, Certifications, etc.

      Software  |  Certifications  | Next DB Table
1     Word          MSIE
2     Delphi        PMI
3                   Experts Exchange
etc.


In the scenario above, each table name is a column heading and values from a specfic field in the table (software name, cert. name, etc) are inserted into the rows.  Notice I excluded other fields the teh detail table, like "Software Title ID".  The numbers on the left are simply the number of records each detail table has for that master record.

Thanks for all of the comments.  If anyone wants to send me an example or better solution -I'm all ears.  Email - 5429314@mcimail.com
0
 

Expert Comment

by:bijoyn
ID: 1359910
I have sent u a mail with some explanation, hope u find it useful.

Bijoy
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1359911
Is it possible to send me that explanation too? Tom.Deprez@uz.kuleuven.ac.be

Regards, Zif.
0
 
LVL 3

Accepted Solution

by:
KE earned 50 total points
ID: 1359912
Hi there,

A late answer. You can add some calculated fields in the to the detail table, which get's their data from the master table.
Dbl-click your table component, and select New field. Adjust the new field, with the field editor, so it matches the master field your'e interested in- Write an OnCalc event-handler to the detail table, which does smth. like this:

DetailTable.FieldByName('MyNewField').AsString := MasterTable.FieldByName('MasterField').AsString;

The reason why you can't have to DataSources connected to a grid, is that it wouldn't know how to navigate your DataSet when requesting new rows etc.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…

680 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