Solved

Sorting within a database grid

Posted on 1997-09-17
6
152 Views
Last Modified: 2010-04-04
I want to be able to have the data listed in a dbGrid be sorted by one (or two) of the fields. The dbGrid's datasource comes from a table which has a master datasource.

I tried specifying the field name I wanted to sort by in the "IndexFieldNames" property, but had a "Index out of range" error.
0
Comment
Question by:BadBart
6 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1345398
Did you try SQL?
0
 

Author Comment

by:BadBart
ID: 1345399
The supervisor of the project does not regard SQL very highly as it takes a much longer time to process.

So, I'm only to use things such as Findkey() and FieldByName().
0
 
LVL 1

Expert Comment

by:anilms
ID: 1345400
Could you be more specific in telling us what type of database table you have (dbf or paradox) and what are the indexes you have created for the table. This would be more useful in getting a proper solution for your needs.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 8

Expert Comment

by:ZifNab
ID: 1345401
I know this is a stupid question, but i'm going to ask it anyway :

When using IndexFieldNames you have to define as index field names in your table structure. Have you done this. Primary and secondary indexes???

Have fun,
c.u. ZifNab;

0
 
LVL 1

Accepted Solution

by:
jturpin earned 50 total points
ID: 1345402
Try using
   try
      .
      .
      .
   SomeName : String;
   YourTable.Close;
   YourTable.AddIndex(SomeName,'Field1;Field2',
      [ixExpression,ixDescending]);
   YourTable.IndexName:= SomeName;
   YourTable.Open;
      .
      ---Processing ---
      .
      .
   finally
      YourTable.Close;
      YourTable.DeleteIndex(SomeName);
      YourTable.IndexName:= '';
      YourTable.IndexDefs.Update;
   end;
0
 

Author Comment

by:BadBart
ID: 1345403
Sorry for the delay! Thanks heaps..!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Strange message in Delphi 10 Seattle 1 464
Delphi cmd execution 6 41
Run video youtube webbrowse 10 45
Reconfigure Delphi Install? 2 36
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 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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

26 Experts available now in Live!

Get 1:1 Help Now