B4J Question DBUtils.Execute... loads first row only

agricult

Member
Licensed User
Hello,
I am a "beginner" with some DB experience 25 years ago in VB and thought I try to use B4X to bridge the gap to android tablets for my sheep program, which I try to convert to B4J first. I hope the members excuse the surely stupid simple problem being posted here.

In my recent test I followed the DBUtils for B4J example of Erel (https://www.b4x.com/android/forum/threads/dbutils-example.34611/#content) but use the modern DBUtils Ver. 2.02 (I found out I can't autofill comboboxes). The problem is that both DBUtils.execute... commands only produce the first row of results (of four in my test Sqlite DB, which I can confirm by sql query in DB Browser for SQLite)

B4X:
#Region Project Attributes
    #MainFormWidth: 400
    #MainFormHeight: 600
    #AdditionalJar: sqlite-jdbc-3.21.0
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private DateOfBirth As Label
    Private FatherID As Label
    Private Gender As RadioButton
    Private bnext As Button
    Private TagID As Label
    Private bnext As Button
  
    Dim sql1 As SQL
    Private TableView1 As TableView
    Private ComboBox1 As ComboBox
End Sub

Sub AppStart (Form1 As Form, Args() As String)
  
    MainForm = Form1
    MainForm.RootPane.LoadLayout("lMain") 'Load the layout file.
    MainForm.Show
'
' 
    sql1.InitializeSQLite(File.DirApp, "files/breedcenter.db", True)
'
    Dim lcombo As List
    lcombo=DBUtils.Executelist(sql1, "SELECT TagID FROM animalDB", Null, 0)
    ComboBox1.Items.AddAll(lcombo)

    DBUtils.ExecuteTableView(sql1, "SELECT TagID FROM animalDB", Null, 0, TableView1)
  
End Sub

Thank you very much for hints and tips to other examples I have missed.

I uploaded breedcenter zip (database) and full test programcode sheepmaster zip
 

Attachments

  • breedcenter.zip
    1.2 KB · Views: 363
  • sheepmaster.zip
    85.4 KB · Views: 364
Last edited:

rboeck

Well-Known Member
Licensed User
Longtime User
Maybe the problem is with the database; can you add the breedcenter.db or export your project as zip...
 
Upvote 0

agricult

Member
Licensed User
Maybe the problem is with the database; can you add the breedcenter.db or export your project as zip...
Thank you, I uploaded the zip files breedcenter.zip (database) and test project sheepmaster.zip (sorry no nice layout yet), I use Java\jdk1.8.0_152\bin\javac.exe
 
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
Hi,

good news: your code is fully ok, but you have several database files - your app use sheepmaster\Objects\files\breedcenter.db, and i think you look in sheepmaster\Files\breadcenter.db - that makes the difference. One tipp beside: you should format a date in this way:yyyy-mm-dd; because sqlite uses text type for dates your format cannot sorted in an easy way.
 
Upvote 0

agricult

Member
Licensed User
Hello,

and thank you very much ! As I thought it was as stupid as it can get..... and also thank you for the tip regarding the date!
 
Upvote 0
Top