Android Question android.database.sqlite.SQLiteException: near ")": syntax error (code 1 SQLITE_ERROR): , while compiling: CREATE TABLE data )

DALB

Active Member
Licensed User
Hello everyone !

A sudden mistake appears in my code this morning without modifying anything !!!

Here is a code I use since days :
I'am loading a B4XTable. It worked fine for days, but this morning, The app renders the following error with this code:

The error:
android.database.sqlite.SQLiteException: near ")": syntax error (code 1 SQLITE_ERROR): , while compiling: CREATE TABLE data )

The code:

loading b4XTable:
Sub chargerLesValeursDansB4Xtable
    
    Dim data As List
    data.Initialize
    Try
        Dim rs As ResultSet = Starter.sql1.ExecQuery("SELECT id, date, fournisseur," & _
        "ville, affectation,montant,numfacture,modepaiement,numcheque,comptepayeur," & _
        "titulaire,sousaffectation,note,codebarres, An,Mois,Jour,amj" & _
        " FROM tachats ORDER BY amj DESC")
        Log("rs.RowCount = " & rs.RowCount)
        Dim t As  String
        Do While rs.NextRow
            Dim n As Int=0
            Dim row(18) As Object
            '-------------------
            t =rs.GetString("amj")
            row(n) = t
            n=n+1
            row(n) = rs.GetInt("id"):n=n+1
            row(n) = rs.GetString("date"):n=n+1
            row(n) = rs.GetString("fournisseur"):n=n+1
            row(n) = rs.GetString("ville"):n=n+1
            row(n) = rs.GetString("affectation"):n=n+1
            row(n) = rs.Getdouble("montant"):n=n+1
            row(n) = rs.GetString("numfacture"):n=n+1
            row(n) = rs.GetString("modepaiement"):n=n+1
            row(n) = rs.GetString("numcheque"):n=n+1
            row(n) = rs.GetString("comptepayeur"):n=n+1
            row(n) = rs.GetString("titulaire"):n=n+1
            row(n) = rs.GetString("sousaffectation"):n=n+1
            row(n) = rs.GetString("note"):n=n+1
            row(n) = rs.GetString("codebarres"):n=n+1
            t=rs.Getint("an")
            row(n) = t
            n=n+1
            row(n) = rs.Getint("mois"):n=n+1
            row(n) = rs.Getint("jour")':n=n+1
            data.Add(row)
        Loop
        rs.Close
        Wait For (B4XTable1.SetData(data)) Complete (Unused As Boolean)
        B4XTable1.SetData(data)
    Catch
        Log("pas possib', erreur")
    End Try

Looking at the forums, I have not found a correct answer for my case.
I'm asking what near ")" means regarding to my syntax.
Is it an error from my code but where or an error detected in the class code ?
Could the B4XTable be crashed ?

Thanks for the ones who comes here.
 

udg

Expert
Licensed User
Longtime User
It seems to refer to a different point in your code.
The message refers to "while compiling: CREATE TABLE data". Try looking at something done during initialization or a missing Sleep(0) in your table definition rows
 
Last edited:
Upvote 0

DALB

Active Member
Licensed User
woow! after a total reset of the app, the B4Xtable remains empty !!!!
Using a classical Table, it fills correctly !
 
Upvote 0

DALB

Active Member
Licensed User
Thank udg.
Apparently, the code seems correct, but when I restarted the app, I obtained an empty table, but after 3 or 4 resets, the error comes again.
...my brain is burning this morning.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Look here. It may be of some help.
Or even at the thread "MYSQL b4xtable code 1 SQLITE_ERROR[1]" in the Similar Threads section below
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
my brain is burning this morning.
Forum members are also burning to help you. If you can reproduce it in a project without giving out confidential data, that would be better because of the amount of fields you have. But it looks like you are duplicating the loading of the B4XTable twice.
Here is your code:
B4X:
Wait For (B4XTable1.SetData(data)) Complete (Unused As Boolean)
        B4XTable1.SetData(data)  'You need to remove this line.
There may also be other problems hard to see from your snippet alone. Also you may want to add sleep(0) after you load the layout as was suggested.
Au Revoir
 
Upvote 0

DALB

Active Member
Licensed User
Hello,

Adding a 'sleep(0)' after this line : rs.close helps a lot.
It seems to solve the incident.
I wait some days and see after many uses.
But for now it's ok.

Thanks much udg and Mahares.
 
Reactions: udg
Upvote 0

DALB

Active Member
Licensed User
ok, thanks Mahares, I'll do it.
 
Upvote 0

DALB

Active Member
Licensed User
referring to the following code which crashed the app for the same problem:

pnlnav must be initialized:
B4XTable1.HeadersHeight=60dip
    Sleep(0)
    Dim pnlNav As B4XView=B4XTable1.lblNumber.Parent

Where pnlNav must be initialized, I found this solution at:


Sleep(0) was added in the code.
Two problems needing a sleep(0) are solved.
 
Upvote 0

DALB

Active Member
Licensed User
B4X team is at the top. Thanks everyone.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…