Solved

Database problem

Posted on 1998-12-10
6
165 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

19 Experts available now in Live!

Get 1:1 Help Now