Android Question [SOLVED] Two B4XTables on Android causes a error?

Discussion in 'Android Questions' started by trejocode, Jun 29, 2019.

Tags:
  1. trejocode

    trejocode Member Licensed User

    Hi all, i use 2 B4XTables in the same project, and i get a error referented to SQLite.
    Has anyone had a similar experience?Has anyone had a similar experience?

    The error:
    Code:
    Error occurred on line: 601 (B4XTable)
    android.database.sqlite.SQLiteException: near 
    ")": syntax error (code 1): , while compiling: CREATE TABLE data )
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:
    889)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:
    500)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:
    588)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:
    58)
        at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:
    31)
        at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:
    1677)
        at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:
    1608)
        at anywheresoftware.b4a.sql.SQL.ExecNonQuery(
    SQL.java:74)
        at maya.caribbean.app.b4xtable._createtable(b4xtable.java:
    1944)
        at maya.caribbean.app.b4xtable$ResumableSub_SetData.resume(b4xtable.java:
    283)
        at maya.caribbean.app.b4xtable._setdata(b4xtable.java:
    222)
        at maya.caribbean.app.moduledetails._loaddata(moduledetails.java:
    412)
        at maya.caribbean.app.moduledetails._activity_create(moduledetails.java:
    396)
        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 maya.caribbean.app.moduledetails.afterFirstLayout(moduledetails.java:
    104)
    The code of the second B4XTable:

    Code:
    Sub Globals   

    Dim Data As List
    Private TableDetails As B4XTable

    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
        
    Activity.LoadLayout("LayoutDetalle")
        
        Data.Initialize
        
        TableDetails.AddColumn(
    "Hola", TableDetails.COLUMN_TYPE_TEXT)
        TableDetails.AddColumn(
    "Productos", TableDetails.COLUMN_TYPE_TEXT)
        
        TableDetails.Clear
        LoadData
        
    End Sub

    Sub LoadData
        
        Data.Add(
    Array("1","2"))
        TableDetails.SetData(Data)

    End Sub
     
  2. emexes

    emexes Well-Known Member Licensed User

    Was this problem resolved?

    As part of looking into another B4XTable query, I had two B4XTables side-by-side in the same activity, no problem.

    But... apparently the data is not actually transferred to the table's internal database within the .SetData call, but a short time later.

    So this could mean that if you have reused the one list to load up both B4XTables, then there might be a mixup happening.

    The bulletproof solution is for each B4XTable to be loaded from its own separate list, ie, one list per table, not reused.

    A flakier solution would be try adding a Sleep(100) after the .SetData call and perhaps after the LoadData call too.
     
  3. mangojack

    mangojack Well-Known Member Licensed User

    Confusion reigns ... I replied to this thread yesterday , advising the solution had been posted in his other thread...

    https://www.b4x.com/android/forum/threads/close-b4xtable-error-when-setdata.107032/


    Again ...

    The problem had nothing to do with using 2 tables ...

    The above error was caused by calling B4XTable.Clear , then later calling B4XTable.SetData ... without resetting /setting Columns.

    I had also stated it would have been an good idea to post the solution for other users...
     
    DonManfred likes this.
  4. emexes

    emexes Well-Known Member Licensed User

    I was working on the basis that: Better twice than never.
    I experienced a similar issue caused when initializing two tables at the same time, and there was no confirmation back from the original poster that their problem was resolved, so it seemed reasonable to post another possible cause with the proviso: If the multiple B4XTables are still not working as expected
    Bonus! Thank you.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice