ORDER BY - some success
Rick Robinson
rickrobinson at attbi.com
Thu Jan 23 12:04:10 CST 2003
I used Vapp to add the two methods explicitly to my database. Now, the
query returns records! However, the recipes are still not sorted by
name...in fact, I am getting the exact same results I was getting
before that prompted this thread. To summarize, this is what I've done:
Used Vapp to add two methods to my database:
nameSort_fld as a VarChar(504) that is Indexed, and has the method
"Upper(rname)" where "rname" is a VarChar field that holds the recipe
names
nameSearch_fld as a VarChar(504) that is Indexed by Words, and has the
method "Upper(rname)"
I added two properties to my "recipe" base object:
nameSortField as VVarChar
nameSearchField as VVarChar
And, the following code to my base object constructor method:
nameSearchField = new VVarChar("nameSearch_fld", 504,"ASCII",
KV_IndexByWords)
nameSearchField.SetMethod("Upper(rname)")
nameSortField = new VVarChar("nameSort_fld",504, "ASCII",KV_Indexed)
nameSortField.SetMethod("Upper(rname)")
I am trying to query the database for all "Dessert" recipes and sort
the results first by Cuisine, then by Name and I put the results in a
list that shows all the Dessert recipes of a particular Cuisine grouped
together and -- ideally -- in alphabetical order. It is this last bit
that is not happening -- ie. no sorting of the recipe by name. Here is
my query:
c = new vCursor(myDataBase,"select
RecID,rname_fld,cuisine_fld,nameSort_fld from recipes where type_fld =
'Dessert' ORDER BY cuisine_fld, nameSort_fld")
I then stick this into an RB listbox with the code:
c.currentPosition = 1
for i = 1 to c.recordCount
me.addrow ""
me.cell(me.lastIndex,0) = c.field("rname_fld").GetString
me.cell(me.lastIndex,1) = c.Field("cuisine_fld").GetString
me.cell(me.lastIndex,2) = c.Field("RecID").GetString
c.currentPosition = c.currentPosition + 1
next
Again, I get all desserts grouped by Cuisine (French, Italian,
American, etc.) in the second column of my listbox, but the names in
the first column are not sorted. (The RecID is a hidden column that I
use to locate the recipe if someone double clicks on it in the listbox.)
Any ideas why the sort is not working?
Rick
More information about the Valentina
mailing list