Table doesnt load all records from SQLite DB

mrjaw

Active Member
Licensed User
Longtime User
Hi!
I am creating a table , view table with Table module, from a SQLite table for records.
My problem is that the sqlite table has 46 records but when I load the records just can I see 44 , the two lost records doesnt show in table view.

The code that I use to load the records from Sqlite table

B4X:
If TableDefectos.IsInitialized = False Then
            TableDefectos.Initialize(Me, "TableDefectos", 6)
            TableDefectos.AddToActivity(PanelDefectos, 0, 2%y, 100%x, 70%y)
      Else
            TableDefectos.ClearAll
      End If
            TableDefectos.SetHeader(Array As String("#","Descripcion","Valor","Grado","Origen","Cant"))
               '
               'Agregando a la tabla
               Dim Cursor1 As Cursor
               Dim Fld(6) As String
               Msgbox(Main.SQL.ExecQuerySingleResult("SELECT count(*) from t_defectos"),"Aviso")
               Cursor1=Main.SQL.ExecQuery("select * from t_defectos")
               '
               Log("Qty Records" & Cursor1.RowCount)
               For i=0 To Cursor1.RowCount - 5
                  Cursor1.Position=i
                  Fld(0)=Cursor1.GetInt("f_id")
                  Fld(1)=Cursor1.GetString("f_descripcion")
                  Fld(2)=Cursor1.GetString("f_valor")
                  Fld(3)=Cursor1.GetInt("f_grado")
                  Fld(4)=Cursor1.GetInt("f_origen")
                  Fld(5)=Cursor1.GetInt("f_cantidad")                  
                  '==========================CREANDO UNA LINEA EN LA TABLA VISTA======================
                  'Agregando a la tabla
                  TableDefectos.AddRow(Array As String(Fld(0),Fld(1),Fld(2),Fld(3),Fld(4),Fld(5)))
               Next
               '            
               TableDefectos.SetColumnsWidths(Array As Int(60dip,350dip,60dip,60dip,60dip,60dip))
               Cursor1.Close            '

Any cluees?
 

mc73

Well-Known Member
Licensed User
Longtime User
A bit confusing. Why are you using Cursor1.RowCount - 5 instead of Cursor1.RowCount - 1 ? But even so, this should lead in showing 4 less items, not 2...:confused:
 
Upvote 0

mrjaw

Active Member
Licensed User
Longtime User
oops!!! U rigth ! I did this change to test. Really is like this For i=0 To Cursor1.RowCount - 1
doesnt show the last two

This code works fine I debug and I see when the row is added but when I scroll the last 2 records doesnt show.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I don't recognize the custom view you are using (tableDefectos name), but probably it has a height property. Perhaps you should check this?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I had issues with the Table class not showing the last record or two. It has to do with different screen size ratios:
Change this line:
B4X:
TableDefectos.AddToActivity(PanelDefectos, 0, 2%y, 100%x, 70%y)
with this one. You may have to tweak and lower the last number if this does not work. Notice I replaced 70%y with 65%y
B4X:
TableDefectos.AddToActivity(PanelDefectos, 0, 2%y, 100%x, 65%y)
 
Upvote 0

mrjaw

Active Member
Licensed User
Longtime User
Weird....

I tested using for a for and same happens

B4X:
If TableDefectos.IsInitialized = False Then
            TableDefectos.Initialize(Me, "TableDefectos", 6)
            TableDefectos.AddToActivity(PanelDefectos, 0, 2%y, 100%x, 70%y)
      Else
            TableDefectos.ClearAll
      End If
            TableDefectos.SetHeader(Array As String("#","Descripcion","Valor","Grado","Origen","Cant"))
               '
               'Agregando a la tabla
               Dim Cursor1 As Cursor: Dim fin As Int
               Dim Fld(6) As String
               Msgbox(Main.SQL.ExecQuerySingleResult("SELECT count(*) from t_defectos"),"Aviso")
               Cursor1=Main.SQL.ExecQuery("select * from t_defectos order by f_id")
               '
               fin=Cursor1.RowCount-1
               fin=70
               Log("Qty Records" & Cursor1.RowCount)
               For i=0 To fin
   
                  Fld(0)=i
                  Fld(1)="yuca-yuca 1"
                  Fld(2)="yuca2"
                  Fld(3)=1
                  Fld(4)=2
                  Fld(5)=3
                  '==========================CREANDO UNA LINEA EN LA TABLA VISTA======================
                  'Agregando a la tabla
                  TableDefectos.AddRow(Array As String(Fld(0),Fld(1),Fld(2),Fld(3),Fld(4),Fld(5)))
               Next
               '            
               TableDefectos.SetColumnsWidths(Array As Int(60dip,350dip,60dip,60dip,60dip,60dip))
               Cursor1.Close

Here I miss 3 lines. Ended in 67 .... ???
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I tested using for a for and same happens
I am sorry. I did not understand your response. Did you change that line as shown in my previous post, because when I look at you code you still show 70%y instead of 65%y. You may have to even lower it further. That is how I solved my issues.
 
Upvote 0
Top