Solved

Database problem

Posted on 1998-12-10
6
170 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
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 …
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…

831 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