B4J Question B4Xtable sql.exception error SOLVED


Licensed User

i try to use b4xtable and i try to set the data like this;

Dim data As List
    Dim row(11) As Object
    row(0) = "a"
    row(1) = "b"
    row(2) = "c"
    row(3) = "d"
    row(4) = "e"
    row(5) = "f"
    row(6) = "g"
    row(7) = "h"
    row(8) = "i"
    row(9) = "j"
    row(10) = "k"
i already set the columns at app start (11 columns with type TEXT

    Dim headers(11) As String = Array As String("סטטוס","שכר לשעה", "היקף משרה", "איזור", "תחום", "שנות ניסיון", "דרישות תפקיד", "תיאור", ",תאריך", "דרוש\ה","שורה")
    Dim headersSize(11) As Float = Array As Float(100,90,110,130,110,100,300,300,110,160,60)
    For x = 0 To headers.Length-1
        Dim mycolumn As B4XTableColumn = b4xtable1.AddColumn(headers(x),b4xtable1.COLUMN_TYPE_TEXT)
        mycolumn.Width = headersSize(x)


Waiting for debugger to connect...
Program started.
Error occurred on line: 635 (B4XTable)
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near ")": syntax error)
at org.sqlite.DB.newSQLException(DB.java:383)
at org.sqlite.DB.newSQLException(DB.java:387)
at org.sqlite.DB.throwex(DB.java:374)
at org.sqlite.NativeDB.prepare(Native Method)
at org.sqlite.DB.prepare(DB.java:123)
at org.sqlite.Stmt.execute(Stmt.java:113)
at anywheresoftware.b4j.objects.SQL.ExecNonQuery(SQL.java:156)
at b4j.example.b4xtable._createtable(b4xtable.java:2035)
at b4j.example.b4xtable$ResumableSub_SetData.resume(b4xtable.java:473)
at b4j.example.b4xtable._setdata(b4xtable.java:412)
at b4j.example.main._fillmyjobclv(main.java:743)
at b4j.example.main$ResumableSub_loadjobs.resume(main.java:876)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:136)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:85)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at anywheresoftware.b4a.keywords.Common$3.run(Common.java:1086)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)

can someone please tell me what i am doing wrong?

thank you guys


Licensed User
ok i found my mistake, i called b4xtable1.Clear before i tried to fill the table. the problem is that this command also clear the columns what means there where no columns anymore and the table could not be filled.

but how do we clear ONLY the items inside the table and refill it with new items? do i have to create each time the columns again?


Licensed User
What about not using CLEAR and instead using the available columns?
To update; just create a new set of data and use SetData(data) to replace the old data in the table.
if i use clear it means i need to create again the columns. is that the reight way to do it?


Licensed User
i guess yes.
ok i understand now how it works. you dont need to create the columns each time. all you do is you create a global list where you store your data. and each time you update that data list like remove item, update item add item you just set again the data to the table and call refresh.

so basically you just modify everything it that datalist call setdata+refresh. this make now much more sense :)

EDIT: ps you dont need to call table.clear if you want to remove all items you just clear the data list and call again setdata+refresh. this will clear the list but keep the columns.