ExecQuery returns no records?

Malky

Active Member
Licensed User
Longtime User
Hi , I have tried various things with this, but cannot retrieve data from the created DB for some reason?

I have even taken the database from the phone and tried the same table on my computer running the same simple query and the data is there using SQL Lite browser! I did this a few times as well to make sure.

Any ideas anyone?

Malky

B4X:
Sub DisplayLangs
   Dim Cursor1 As Cursor
      Cursor1 = SQL1.ExecQuery("selec1 * from wp_langs order by lang")
      Log("count = " & Cursor1.Rowcount)
      For i=0 To Cursor1.RowCount - 1
         Cursor1.Position = i
         Dim job As HttpJob
         Log(Cursor1.GetString("lang"))
         imagename = Cursor1.Getstring("flag")
         job.Initialize(imagename, Me)
         job.Download(URL & "images/prop_apps/thumbs/langs/" & imagename)
         Log(URL & "images/prop_apps/thumbs/langs/" & imagename & " - " & job.Success)
         bmp = LoadBitmap(SD_PATH, imagename)
         LangView.AddTwoLinesAndBitmap2(Cursor1.Getstring("lang"),Cursor1.Getstring("abbrev"),bmp,Cursor1.Getstring("abbrev"))
      Next
      Cursor1.Close
      
End Sub
 

barx

Well-Known Member
Licensed User
Longtime User
May be a silly question but without reading through the code...

have you moved the database from assets to a writable location?
 
Upvote 0

Malky

Active Member
Licensed User
Longtime User
Hi Klaus, I had to change the code" to selec1 otherwise it wouldn't post on the forum. I don't know how you managed it, but I can't use the word even in this post?

The external folder must have writeable privileges as the database is created correctly and the records are actually written into the db?
After testing the same db on my computer and viewing the records, I deleted it from the phone's external drive and did the same process, again check the db on my computer and the records once again exist?

Malky
 
Upvote 0

Malky

Active Member
Licensed User
Longtime User
Certainly, file is attached.

Thank you for your help.

Malky
 

Attachments

  • homerbg.zip
    10.1 KB · Views: 285
Upvote 0

Malky

Active Member
Licensed User
Longtime User
The database is created via the app.

The one I created and copied is attached if you need it.

Cheers,

Malky
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I finally got it.
The problem has nothing to do with code for SQL queries.
The problem is that the routine DisplayLangs in Activity_Create is called before the database is filled.
If you move this line at the end of the Sub hc_ResponseSuccess routine just after SQL1.EndTransaction it works as you expect it !

Best regards.
 
Upvote 0

Malky

Active Member
Licensed User
Longtime User
Hi Klaus, I have moved the DisplayLangs call to where you suggest, but I still get a count =0 in my log file?

My listview obviously doesn't appear?

Am I missing something?

Thanks,

Malky
 
Upvote 0

Malky

Active Member
Licensed User
Longtime User
Hi again Klaus, you have me on the right track now, and the db is populated, BUT... there's always a but, it seems the second image file is not downloaded in time.
The result is my listview opens with the first list and image, but I get an error saying the second one doesn't exist?

I probably need a way to check and keep checking?

Malky
 
Upvote 0
Top