B4J Question [SOLVED] B4XTable SetData with ExecutList as source. Is it possible?

jroriz

Active Member
Licensed User
Longtime User
I am using a resultset to load a B4XTable as suggested in the post "[B4X] B4XTable - Load data from SQL database".
OK, everything is working fine.

But my first attempt was:

B4X:
    B4XTable1.AddColumn("Jogador", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.SetData( DBUtils.ExecuteList(Main.Banco, "SELECT jogador FROM resultados", Null, 0) )

which made sense to me, since SetData expects a list and ExecutList returns a list. However, this produces the error below.

Am I doing something wrong or does SetData not allow ExecutList as source?

 

jroriz

Active Member
Licensed User
Longtime User
Would this be possible for multiple columns? (SELECT dtin, jogador, valor FROM resultados)
 
Upvote 0

jroriz

Active Member
Licensed User
Longtime User
yes. make sure to create a array of the correct size (and all Rows having the same columncount (array of same size)).
It seems that I will end up stuck with the code very similar to the link of the post # 1 ...
 
Upvote 0

jroriz

Active Member
Licensed User
Longtime User
You should use DBUtils.ExecuteMemoryTable. You might need to go over the list and modify the arrays. Try it and post the results.
B4X:
    B4XTable1.AddColumn("Dtde", B4XTable1.COLUMN_TYPE_DATE)
    B4XTable1.AddColumn("Jogador", B4XTable1.COLUMN_TYPE_TEXT)

    Dim data As List
    data.Initialize
    For Each row() As String In DBUtils.ExecuteMemoryTable(Main.Banco, "SELECT Dtde, Jogador FROM resultados", Null, 0)
        data.Add(row)
    Next
    
    B4XTable1.SetData(data)

That simple!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…