Problem with database sqllite

fanfalveto

Active Member
Licensed User
Longtime User
I have a database with several fields. To row 250 the program reads well, but ignores 251 onwards. please if you can help? thanks
 

fanfalveto

Active Member
Licensed User
Longtime User
in globlals
B4X:
dim preg as int=1
In activity_create
B4X:
If FirstTime = True AND File.Exists(File.DirInternal, "base.db") = False Then
        File.Copy(File.DirAssets, "base.db", File.DirInternal, "base.db")      
    End If      
    SQL1.Initialize(File.DirInternal, "base.db", True)
then
B4X:
Sub juego
Label8.Text=preg
Cursor1=SQL1.ExecQuery("SELECT pregunta,r1,r2,r3,r4 FROM table1 WHERE id=" &preg)
    For i = 0 To Cursor1.RowCount - 1   
      Cursor1.Position = i
    la1=(Cursor1.GetString("pregunta"))
   r1=(Cursor1.GetString("r1"))
   r2=(Cursor1.GetString("r2"))
   r3=(Cursor1.GetString("r3"))
   r4=(Cursor1.GetString("r4"))
   If pos=1 Then
   Label1.Text=la1
   Label2.Text=r1
   Label3.Text=r2
   Label4.Text=r3
   Label5.text=r4
   Else If pos =2 Then
   Label1.Text=la1
   Label3.Text=r1
   Label4.Text=r2
   Label5.Text=r3
   Label2.text=r4
   Else If pos =3 Then
   Label1.Text=la1
   Label4.Text=r1
   Label5.Text=r2
   Label2.Text=r3
   Label3.text=r4
   Else If pos =4 Then
   Label1.Text=la1
   Label5.Text=r1
   Label2.Text=r2
   Label3.Text=r3
   Label4.text=r4
   End If
   Next
   Cursor1.Close
   Label7.Text="Nivel: "&nive
   Label6.Text="Puntos: "&punto
   Label9.Text="Fallos: "&fallo
End Sub
if click a button then
B4X:
preg=preg+1
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Replace your sub with this or just add the two logging lines marked with comments to yours. Run the app and see what the log shows:

B4X:
Sub juego
   Label8.Text=preg
   Cursor1=SQL1.ExecQuery("SELECT pregunta,r1,r2,r3,r4 FROM table1 WHERE id=" &preg)
   Log(Cursor1.RowCount - 1)   'Added for logging
   For i = 0 To Cursor1.RowCount - 1
      Cursor1.Position = i
      Log(Cursor1.Position)   'Added for logging
      la1=(Cursor1.GetString("pregunta"))
      r1=(Cursor1.GetString("r1"))
      r2=(Cursor1.GetString("r2"))
      r3=(Cursor1.GetString("r3"))
      r4=(Cursor1.GetString("r4"))
      If pos=1 Then
         Label1.Text=la1
         Label2.Text=r1
         Label3.Text=r2
         Label4.Text=r3
         Label5.text=r4
      Else If pos =2 Then
         Label1.Text=la1
         Label3.Text=r1
         Label4.Text=r2
         Label5.Text=r3
         Label2.text=r4
      Else If pos =3 Then
         Label1.Text=la1
         Label4.Text=r1
         Label5.Text=r2
         Label2.Text=r3
         Label3.text=r4
      Else If pos =4 Then
         Label1.Text=la1
         Label5.Text=r1
         Label2.Text=r2
         Label3.Text=r3
         Label4.text=r4
      End If
   Next
   Cursor1.Close
   Label7.Text="Nivel: "&nive
   Label6.Text="Puntos: "&punto
   Label9.Text="Fallos: "&fallo
End Sub
 
Upvote 0

fanfalveto

Active Member
Licensed User
Longtime User
I don´t know only see in log 0 when program runs to row 250 and after -1.
may be is problen the program to make the database don´t make more than 250 rows.i do that with sqlite expert
 
Upvote 0

fanfalveto

Active Member
Licensed User
Longtime User
the data base is not empty,i play the game to row 250 and it´s ok,i see the database in dat/data/myprogram/files and only there are 250 rows.
sure is a problem whit sql expert,i try to create another database from 251 to 500 or use another application to create.
 
Upvote 0

fanfalveto

Active Member
Licensed User
Longtime User
well i don´t know i try to make another database.
if i can´t do then post again for help.
Thank you very much
 
Upvote 0
Top