Android Question DBUtils.ExecuteMemoryTable Problem

powerino

Active Member
Licensed User
Hi, I have a table with 3 record and i want to "export" in a List, using DBUtils.ExecuteMemoryTable.

List.size is correct, but if i display the "record" in List, i see some like this:

[Ljava.lang.String;@26bd3b0
[Ljava.lang.String;@88aff12
[Ljava.lang.String;@b3dc0d1

and not this:

"forno" 1
Tubo" 4
"vetro" 12

why?

this is my code, thanks for help
B4X:
Sub btnExport_Click
    
    

    Dim lista As List
    
    lista=DBUtils.ExecuteMemoryTable(Connection.mySQL, "SELECT * FROM LavoroTB", Null, 0)
    Dim str As String
    
    'Msgbox(lista.Size,"")
    For i=0 To lista.Size-1
        str=lista.Get(i)
        Msgbox (str  ,"")
    Next
    

    
End Sub
 

William Lancee

Well-Known Member
Licensed User
Longtime User
Each item in the list is an ARRAY of strings that represents a record in the result set.

Something like...

B4X:
    Dim str() As String
    
    'Msgbox(lista.Size,"")
    For i=0 To lista.Size-1
        str=lista.Get(i)
        for each s as string in str
            Msgbox (s  ,"")
        next
    Next
 
Upvote 0

powerino

Active Member
Licensed User
at line 6 i have this error:

java.lang.RuntimeException: Method: getSize not found in: java.lang.String
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
I don't know what you have in lista...

B4X:
Dim lista As List
lista=DBUtils.ExecuteMemoryTable(Connection.mySQL, "SELECT * FROM LavoroTB", Null, 0)


But the following works fine:

B4X:
    Dim lista As List: lista.initialize
    lista.Add(Array As String("aaa", "bbb", "ccc"))
   
    Dim str() As String
    For i=0 To lista.Size-1
        str=lista.Get(i)
        For Each s As String In str
            Log(s)
        Next
    Next
 
Upvote 0

powerino

Active Member
Licensed User
maybe this is the problem:
lista=DBUtils.ExecuteMemoryTable(Connection.mySQL, "SELECT * FROM LavoroTB", Null, 0)

but i don't know if is correct this code (query is ok)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Please post all your questions in the B4A Qustion forum. They are not related to this forum.
 
Upvote 0
Top