Android Question B4XTable Error on reloading data

james_sgp

Active Member
Licensed User
Longtime User
Hi, I have been using B4XTable in many apps without a problem. But today I`ve come across something that I`m baffled by; I have a panel with a B4X table which is filled from a remote SQL table. When I first load the data in the table there is no issue, but when I hide and re-show the panel; the table is blank and re-loading gives me the error below, I have also included the code I`mm using. The error occurs at line "members_table.SetData(data)"; any tips greatly appreciated.

James


*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
closing old db.
Error occurred on line: 635 (B4XTable)
android.database.sqlite.SQLiteException: near ")": syntax error (code 1 SQLITE_ERROR[1]): , while compiling: CREATE TABLE data )
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1229)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:703)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:2227)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:2155)
at anywheresoftware.b4a.sql.SQL.ExecNonQuery(SQL.java:74)
at event.access.b4xtable._createtable(b4xtable.java:2121)
at event.access.b4xtable$ResumableSub_SetData.resume(b4xtable.java:470)
at event.access.b4xtable._setdata(b4xtable.java:409)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7050)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
** Service (httputils2service) Destroy **

B4X:
    Dim members_job As HttpJob
    DateTime.DateFormat = "dd/MM/yyyy HH:mm:ss"
    If Connected = True Then
        members_job.Initialize("", Me)
        members_job.Download(strURL & "member.php")
        Wait For (members_job) JobDone(members_job As HttpJob)
        If members_job.Success Then
            Dim data As List
            data.Initialize
            Dim strReturn As String = members_job.GetString
            Dim parser As JSONParser
            parser.Initialize(strReturn)
            Dim Members As List
            Members = parser.NextArray 'returns a list with maps
            For i = 0 To Members.Size - 1
                Dim m As Map
                m = Members.Get(i)
                data.Add(Array(m.Get("ID"),m.Get("event_name"),m.Get("qr_code"),DateTime.Date(m.Get("date_stamp"))))
            Next
            members_job.Release
        End If
    End If
    members_table.SetData(data)
    members_table.ArrowsDisabledColor = xui.Color_gray
    members_table.ArrowsEnabledColor = xui.Color_Black
    members_table.lblNumber.TextColor = members_table.ArrowsEnabledColor
    members_table_DataUpdated
 
Last edited:

OliverA

Expert
Licensed User
Longtime User
If Connected is ever False or members_job.Success is ever false, data will be an uninitialized list. That may pose a problem. An empty list may also (no clue if Success = True gives you at least one record)
 
Upvote 0

james_sgp

Active Member
Licensed User
Longtime User
Thanks, a good point; I`ve added a check to make sure the list has data or else t won`t populate the table.
 
Upvote 0

james_sgp

Active Member
Licensed User
Longtime User
SOLVED!!!
Ok, found the error. I had a table Clear command hidden elsewhere in the code. After removing that, all is good again.
 
Upvote 0
Top