Android Question Result SET don't see column

akinnovation

Member
Licensed User
Longtime User
Hi all,
I'm developing an app with b4xtable and I wish to import data from a sqllite DB.
I have used the Erel's tutorial (B4XTable - Load data from SQL database).
Result set error:
Dim rs As ResultSet = sql.ExecQuery("SELECT coalesce(via,"") as via, coalesce(nome_azienda,"") as cliente,  coalesce(citta,"") as citta, coalesce(note,"") as note FROM sopralluoghi")
    Do While rs.NextRow
        Dim row(4) As Object
        row(0) = rs.GetString("cliente")
        row(1) = rs.GetString("via")
        row(2) = rs.GetString("citta")
        row(3) = rs.GetString("note")
        Data.Add(row)
    Loop
    rs.Close
When I execute the app I have this error:
error:
Logger connesso a:  Meberry M7
--------- beginning of crash
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
*** mainpage: B4XPage_Created
Error occurred on line: 72 (B4XMainPage)
java.lang.IllegalArgumentException: column "via" does not exist. Available columns:[B] [/B][cliente, note]
    at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:352)
    at anywheresoftware.b4a.sql.SQL$CursorWrapper.GetString(SQL.java:377)
    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:348)
    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.debug.Debug.delegate(Debug.java:262)
    at ak.sopralluogo.b4xmainpage._b4xpage_created(b4xmainpage.java:97)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1058)
    at ak.sopralluogo.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1070)
    at ak.sopralluogo.b4xpagesmanager._showpage(b4xpagesmanager.java:427)
    at ak.sopralluogo.b4xpagesmanager._addpage(b4xpagesmanager.java:247)
    at ak.sopralluogo.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:261)
    at ak.sopralluogo.b4xpagesmanager._initialize(b4xpagesmanager.java:167)
    at ak.sopralluogo.main._activity_create(main.java:451)
    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 ak.sopralluogo.main.afterFirstLayout(main.java:105)
    at ak.sopralluogo.main.access$000(main.java:17)
    at ak.sopralluogo.main$WaitForLayout.run(main.java:83)
    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)
From the log I can see that the only columns in the result set are "cliente" and "note", if I change the query in " select cliente, via,...." I have the same error, but the column in result set are "via" and "note". Seems that only even columns are inserted in result set.
Please help .
Many thanks .
Marco
UPDATE:
I have changed the query in "select * from...." and all seems work fine. Why ? I have just used sqllite db in other app and all work ?
Many thanks
Marco
 
Last edited:

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
Syntax error , you used double quotes " inside the select:
Dim rs As ResultSet = sql.ExecQuery("SELECT coalesce(via,"") as via, coalesce(nome_azienda,"") as cliente, coalesce(citta,"") as citta, coalesce(note,"") as note FROM sopralluoghi")

the correct is using single quote ' as the following:
B4X:
Dim rs As ResultSet = sql.ExecQuery("SELECT coalesce(via,'') as via, coalesce(nome_azienda,'') as cliente, coalesce(citta,'') as citta, coalesce(note,'') as note FROM sopralluoghi")
 
Upvote 0
Top