Android Question Weird problem with DBUtils.ExecuteSpinner

pantaraf

Member
Licensed User
Longtime User
Hi everyone,
I'm facing a weird problem using DBUtils.ExecuteSpinner. I use it in other parts of my projects without a problem. The weird behaviour is the following (both spinner are initialized as Spn1.Initialize("") at Activity_Create sub). They are loaded with data from two different tables both of them populated. In other parts of the project the very same statements work flawlessly. In the following point I can reproduce two different strange behaviours. I've followed all the code in DBUtils too, the strangest thing is that table are queried correctly, so I can see DBUtils load right values from SQLite DB, but after exiting the sub the spinners are loaded weirdly: in one case the first one is loaded with second one data while the second one is empty; if I move DBUtils.ExecuteSpinner at the end of sub both of them are loaded with second one data. :confused: Am I doing something really wrong? :D

B4X:
      modifica=False
      nuovo=True
      lvApiari.Enabled=False
      spn2.Clear
      spn1.Clear
      ScrollView1.Panel.LoadLayout("BigPanel")
      ScrollView1.Panel.Height=altpannello       
      ScrollView1.FullScroll(False)
      pnlAnagrafica.enabled=True
      btnSave.Text="Salva"
      sbForza.Value=5
      lblValForza.Text="5"
      DBUtils.ExecuteSpinner(Main.SQL, "SELECT DESC FROM TABLE2 ORDER BY ID", Null, 0, spn2)
      DBUtils.ExecuteSpinner(Main.SQL, "SELECT TYPE FROM TABLE1 ORDER BY ID", Null, 0, spn1)
Thank you.
Raffaele
 

LucaMs

Expert
Licensed User
Longtime User
Seeing it so there are no problems.

The only thing (but does not affect) is that you have a field called DESC which is a keyword in SQL (DESCending).

(Ricordati che esiste anche il forum italiano :p)
(Remember that there is also the Italian forum)
 
Upvote 0

pantaraf

Member
Licensed User
Longtime User
Ciao Luca,
thanks, I know DESC is a reserved SQL word, I've just changed the real sql column name to make it more readable. The actual SQL statement works flawlessly.
 
Upvote 0

pantaraf

Member
Licensed User
Longtime User
I beg your pardon Erel, but the very same code in other parts of the project just works as it should. If the spinners wouldn't be initialitied properly shouldn't I notice strange behaviours from other sub as well?
Is spn1.Initialize("") an allowed method to do it or not?
I have one doubt about it though. Both the spinners are placed on a secondary layout I load using Scrollview1.Panel.LoadLayout("layoutnname"), is it a problem if I initialize them before the layout is loaded, I mean I initialize them in Activity_Create before loading the layout.

Thank you.
Raffaele
 
Upvote 0

pantaraf

Member
Licensed User
Longtime User
I'm trying to put this piece of code into a new sub and call it from each point that now use it, something like "Sub LoadSpinners" :).
I'll get you informed about...
 
Upvote 0

pantaraf

Member
Licensed User
Longtime User
You know what? Moving both lines of DBUtils.ExecuteSpinner... into a new Sub LoadSpinners and calling it from two different point of code made it work... o_O
 
Upvote 0
Top