Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Database problem

Posted on 1998-12-10
6
Medium Priority
?
176 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
[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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

604 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