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
Solved

Database problem

Posted on 1998-12-10
6
171 Views
Last Modified: 2010-04-04
I'm trying to link 2 TTable with the MasterSource and MasterField properties. Everything is OK except that the order of the data in the Detail TTable is completely mixed up. I'm using Access to generate the tables. Even adding indexes doesn't help. How can I get data to display in the same order as it was originally created?
0
Comment
Question by:willemnel
  • 4
6 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1350471
Can you give a portion of your source?

You do have set the correct indexes for your table (which delphi has to use)?

Zif.
0
 

Accepted Solution

by:
forns earned 20 total points
ID: 1350472
Hi, Willemnel.
First of all: if no "IndexFieldName" or "IndexName" is specified to order a table Delphi uses the table keys to do it. If you want the second TTable to be ordered as it was created, the only way I know is adding a field that just saves the record numbers of the records in the second table relative to the master (1st. table), so if you've got this in the 1st. table:
1 -> John
2 -> Mike
3 -> Albert
(where the first field is the person's code and the second one is his name)
and John and Albert have one phone number, but Mike's got three, the 2nd. table should be like this:
1 -> 1 -> 555-41-54
2 -> 1 -> 555-12-13
2 -> 2 -> 555-65-98
3 -> 1 -> 555-85.12
(where the first field is the person's code, the second one is a counter to indicate the phone number "code" relative to the person and the first field is the person's phone(s)).

I think I didn't explain very well, but I hope it helps.

See you!
0
 

Expert Comment

by:forns
ID: 1350473
Ooops!

Sorry, Mike's got only 2 phone numbers.
I forgot: the second table's index field should be it's second field.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
LVL 1

Author Comment

by:willemnel
ID: 1350474
fors - I've tried the above with no success. It STILL gives the records in random order. I have solved the problem using a TQuery with a SQL statement ("order by ... "). I'll give you points for trying. :)
0
 

Expert Comment

by:forns
ID: 1350475
Thanks much, willemnel, but I prooved my coded myself and it did work. As I told you, the only thing you've got to do is adding a field in the second table, wich contents the record number relative to the master record (from the first table).
When you add a record on the second table it should have a master in the first one, so you've got to count how many detail records has the second table at this time and add n+1 as the value of the "RelativeRecordNumber" field in the second table.

I know it is not easy to see this way, but you should try it anyway, cuz making use of TQuery much times in an app uses a lot of time and speeds down you app. performance.

I'd be glad if you tell me if you try it.

See you!
0
 

Expert Comment

by:forns
ID: 1350476
I forgot something agin!

The easiest way to solve your problem is working with just ONE table that should content the whole fields you need. That gives much better results and is the most logical way to work in 1:1 relationed tables.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 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