httputils2 help with mySQL Execution by waiting for a job to be done

jdiperla

Member
Licensed User
Longtime User
I am trying to update a listview with information from a table. I have a book and an author and then the cover of the book. I wanted to add each book with those details to the listview.

In the logs, everything loops through the mySQL database very well and gets all the records. However, the httputils2 will only download the last record.

Here is my code:

For public globals:
B4X:
Dim curbookcase as int

When the button is pressed:

B4X:
Dim mh1 As MysqlHandler
    Dim rs1 As ResultSet
       mh1.Initialize("ALL MY CONNECTION INFO")
    If mh1.isConnected = False Then
        Msgbox(mh1.SQLError, "Connection Error:")
        Return
    End If
   
      rs1 = mh1.Query("SELECT * FROM  `bookdb` WHERE  `drama` LIKE  'yes' LIMIT 0 , 30")
 
 If rs1.IsInitialized = False Then
        Msgbox("ResultSet is empty" & CRLF & mh1.SQLError, "Warning")
        Return
    End If

      
   
    
   
release_dljpg
flagload = False
Listview1.Clear
Listview1.Clear
If flagload = False Then

For i=0 To rs1.RowCount - 1
 rs1.Position = i
curbookcase = 0
Do While curbookcase = 0
gbook = rs1.GetString2("bookname")
gbookauthor = rs1.GetString2("author")
dljpg(i).Initialize(rs1.GetString2("bookname"), Me)
dljpg(i).Download(rs1.GetString2("imglink"))
Loop
Next

End If

Then in the Job Done:

B4X:
If Job.Success = False Then
Job.Release
Return
End If

   
'------------------------------------------------
   Select Job.JobName
      Case curbookcase
      
If Job.Success = False Then
Job.Release
Return

End If
   If Job.Success = True Then
        
      Bitmap1.Initialize3(Job.GetBitmap)
   Listview1.AddTwoLinesandBitmap(gbook, "By: " & gbookauthor, Bitmap1)
      Job.release
      
   End If
   Return
   '---------------------------------------------
   
   curbookcase = 1
   End Select


I have no idea how to make the image appear on the listview for each item in my table. I tried Loops and timers and still can not figure it out. Any modifications to this code I have?
 

jdiperla

Member
Licensed User
Longtime User
Well in short, I am trying to populate a listview by pulling records from a mysql database. I am using the MySQL Library and the httputils2 library to perform that operation.

I am not sure if its an issue with HTTPUTILS2 or the MySQL Library. But it seems to only pull and populate the listview with the last record in the database.


I will see if that link does something different. Thanks.
 
Upvote 0

jdiperla

Member
Licensed User
Longtime User
Well, I will say that it works if I do not do the images. It actually lists everything. If I do the images, the list only puts the last item on the database. I tried using the custom listview option too, same deal.

Hmmm..
 
Upvote 0

jdiperla

Member
Licensed User
Longtime User
I believe I did, but it still didn't fix the problem. However, I was able to get the problem resolved by simply using Global flags/variables. Probably not the best type of code to use, but it did the job. Thanks for your help though.
 
Upvote 0
Top