Solved

Order By in Visual Fox Pro  6.0

Posted on 2011-03-09
3
621 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
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 41

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 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

12 Experts available now in Live!

Get 1:1 Help Now