[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sorting within a database grid

Posted on 1997-09-17
6
Medium Priority
?
176 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
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 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 200 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

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.

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…
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…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month19 days, 21 hours left to enroll

872 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