Page 1 of 1

DBLib and using OrderBy

Posted: Wed Oct 02, 2013 7:45 am
by nicoloose
I am using DBLib to return a set of values from an sqlite database in a specific order but I am having a problem creating a combobox which displays the correct order. If I debug and step through the code, the array when returned from the query is correctly ordered. When the following piece of code is executed, the resulting combobox is not in the correct order:

dbOrderBy "supplierName"
put dbGet("suppliers") into allSuppArray
put CR into sComboBox
repeat for each line sKey in (the keys of allSuppArray)
put allSuppArray[sKey]["supplierName"] & CR after sComboBox
end repeat

Can anyone shed some knowledge please?
Thanks

Re: DBLib and using OrderBy

Posted: Fri Oct 04, 2013 8:11 am
by nicoloose
Good day,

Anyone able to tell me why the foreach statement below does not start on the first key in (the keys of myArray)? For some reason, it begins at a random number, normally 8 so my drop down combo box is never in the order that I want it.

Please help. I am stuck.
Cheers
N

Re: DBLib and using OrderBy

Posted: Fri Oct 04, 2013 9:05 am
by Simon
Hi nicoloose,
DBLib is not a liveCode product. Go to where you downloaded the product from, there is a forum there for your questions.

Simon

Re: DBLib and using OrderBy

Posted: Fri Oct 04, 2013 9:09 am
by nicoloose
Hi Simon,

Thanks for the reply. This is not actually a DBLib issue I have discovered. I have recreated this by constructing a simple sql statement and returning an array which as I mentioned, is in the order that I want. As soon as i perform a foreach statement on the array, this is when the order becomes jumbled up. In the debugger, "sKey" in the foreach statement never starts at "1" for some reason?

repeat for each line sKey in (the keys of allSuppArray)
put allSuppArray[sKey]["supplierName"] & CR after sComboBox
end repeat

Regards
Nic

Re: DBLib and using OrderBy

Posted: Fri Oct 04, 2013 9:22 am
by Simon
Hi Nic,
Not sure, but is this in:
http://lessons.runrev.com/s/lessons/m/4 ... t-an-array
in which split and element are used?

Simon