Solved

Order By in Visual Fox Pro  6.0

Posted on 2011-03-09
3
650 Views
Last Modified: 2012-05-11
Hello Experts,

I have code like this:

Code Snippet:
IF USED("Results")
      SELECT Results
ELSE
      SELECT 0
      USE Results
ENDIF
CURSORSETPROP("buffering",3)


 I need the Results table(or DBF) file to be Order by Datetime, since the table contains the datetime field.

How can I do that in Fox Pro 6.0
0
Comment
Question by:ASPDEV
[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
3 Comments
 
LVL 1

Expert Comment

by:hiraben
ID: 35088096
Any of these:

1) You can use: select * from results order by datetime --> this won't be updatable (changes won't be saved)
2) you can use: sort to results_ordered on datetime
3) you can create a local view on the results table and set the order to datetime. This requires creating a database, but it is the best solution because it is updateable
0
 
LVL 42

Accepted Solution

by:
pcelba earned 500 total points
ID: 35088233
The easiest thing you can do is INDEX.

SELECT Results
INDEX ON datetimeField TO (SYS(2023)+"\TmpIndex") COMPACT

and from now the table is ordered as you need. This kind of index is a bit temporary and it is not updated by other instances which use same DBF. If you need something more "permanent" and updated from all users then you should add index tag into the structural index file:

USE Results EXCLUSIVE
INDEX ON datetimeField TAG SomeName
USE

And from now when you need the table ordered by datetimeField simply issue:

SET ORDER TO TAG SomeName

The tag name must be up to 10 characters. You may also decide about the ascending or descending order.
0
 

Author Closing Comment

by:ASPDEV
ID: 35088573
Excellent!

Thanks,
ASPDEV
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

734 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