Android Question b4xtable.setdata

akinnovation

Member
Licensed User
Longtime User
Hi,
I try b4xtable, but when I call .setdata I have this error
error:
Col 0 Trasporto merci
Col 0 Trasporto merci e rel. posizionamento
Col 0 Trasporto rifiuti
Col 0 Trasporto eccezionale
Col 0 Sollevamento
Col 0 Pulizia industriale
Col 0 Ricondizionamento rifiuti
Col 0 Demolizione/smontaggio impianti tecnologici
Col 0 Distacco
Col 0 Trasporto smaltimento e facchinaggio rifiuti
Col 0 Trasporto e smaltimento rifiuti
Error occurred on line: 704 (B4XTable)
android.database.sqlite.SQLiteException: near ")": syntax error (code 1 SQLITE_ERROR): , while compiling: CREATE TABLE data )
    at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:986)
    at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:593)
    at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:61)
    at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:33)
    at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1805)
    at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1733)
    at anywheresoftware.b4a.sql.SQL.ExecNonQuery(SQL.java:74)
    at ak.sopralluogo.b4xtable._createtable(b4xtable.java:2365)
    at ak.sopralluogo.b4xtable$ResumableSub_SetData.resume(b4xtable.java:287)
    at ak.sopralluogo.b4xtable._setdata(b4xtable.java:220)
    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:146)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:7171)
    at android.view.View.performClickInternal(View.java:7148)
    at android.view.View.access$3500(View.java:802)
    at android.view.View$PerformClick.run(View.java:27409)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7642)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:503)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
and the code for this:
B4X:
Private Sub copiaS_Click
    ServiziScelti.Clear
    servizi.Add(serviziC.SelectedItem)
    ServiziScelti.SetData(servizi)
"servizi" is a list declared as public in "class globals" of b4xmainpage
"serviziC"is a b4xcombo and "ServiziScelti" is b4xtable configured in this manner
B4X:
    ServiziScelti.AddColumn("Servizio",ServiziScelti.COLUMN_TYPE_TEXT)
    servizi.Initialize
the table has only one column.
If I watch the "servizi" list before call "setdata" I see the list with the text I wish to see into the table

Any help is welcome.
Thanks
Marco
 

Mahares

Expert
Licensed User
Longtime User
the table has only one column.
Even though your table has one column, the list that makes up the table is expected to be a list of array of strings. Therefore, instead of:
B4X:
servizi.Add(serviziC.SelectedItem)
    ServiziScelti.SetData(servizi)
Try this:
B4X:
servizi.add(Array(serviziC.SelectedItem))
        
        ServiziScelti.SetData(servizi)
If this does not solve it for you, please post the full code to extract the list and populate the table
 
Upvote 1
Cookies are required to use this site. You must accept them to continue using the site. Learn more…