Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Row numbers in Grid
Message
From
07/03/2005 13:28:40
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00993302
Message ID:
00993353
Views:
14
>Trouble is the original data to be shown in the grid won't necessarily be in record order, i.e. in an index order, so won't this have an inaccurate/meaningless row number in the grid? Not being 8-literate,. of course, I don't know what the Cast bit is doing though.

Indeed. That is why I did not add a RECNO() field to the original query which could come from several joined tables, and in any case you'd not be guaranteed a proper record number in the result. I did mention it is not a good design relying on record numbers. Inmy example to him I created a blank column, then filled it with recno() from the resulting cursor.

As for Cast() it's in VFP9, not 8. It was added to increase SQL Server compatibility. It allows you to define the type and size of the resulting column in the query itself. Among other things it fixes the kludgy method of saying '000 as MyNumber' to get a 3-digit numeric. Else you'd get whatever length the first record happens to be and truncated record since.

CAST is much cleaner. Another good reason to upgrade to VFP9!


I also realized I misquoted the VFP8 line. Should be
* in VFP8
Select f1,f2,00000 as rownumber from MyTable Into Cursor dummy readwrite
without the type definition. I guess I got used to using CAST()<g>



>>Depending on row number is generally not a good design. If you want to show it, then you could add a column to your controlling cursor:
>>
>>* in VFP9
>>Select f1,f2,Cast(0 as integer) as rownumber from MyTable Into Cursor dummy readwrite
>>* in VFP8
>>Select f1,f2,00000 as n(5,0) as rownumber from MyTable Into Cursor dummy readwrite
>>
>>* then
>>replace all rownumber with recno()
>>
>>* now go to show grid...
>>


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform