DBLib and using OrderBy

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
nicoloose
Posts: 99
Joined: Mon Sep 16, 2013 3:35 pm

DBLib and using OrderBy

Post by nicoloose » Wed Oct 02, 2013 7:45 am

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

nicoloose
Posts: 99
Joined: Mon Sep 16, 2013 3:35 pm

Re: DBLib and using OrderBy

Post by nicoloose » Fri Oct 04, 2013 8:11 am

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: DBLib and using OrderBy

Post by Simon » Fri Oct 04, 2013 9:05 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

nicoloose
Posts: 99
Joined: Mon Sep 16, 2013 3:35 pm

Re: DBLib and using OrderBy

Post by nicoloose » Fri Oct 04, 2013 9:09 am

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: DBLib and using OrderBy

Post by Simon » Fri Oct 04, 2013 9:22 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply