Android Question Displaying SQLQUERY OUTPUT under JRDC2 implementation in a B4XTable

beelze69

Active Member
Licensed User
Longtime User
Hi,

This is with regards to the JRDC2 implementation shown in the link


I would like to show the output of the SQL Query in a B4XTable.


In the 'config.properties' file under JRDC I have named a Select statement as 'selectAllStoreData'. The database is MYSQL.


The key subroutine in b4A:

Sub getRecord()
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("selectAllStoreData", Null)
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
If j.Success Then

'HERE I WANT TO DISPLAY THE OUTPUT IN A B4XTABLE .. How should I write the code ?
..... end if
...
...

end sub

My doubt:

1) What code should I write above in order to display the output in a Table ?


Please help.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

It doesn't matter where the data comes from. You need to create the 'data' list which is a List of arrays of objects. Each array will be added as a single row.

B4X:
req.HandleJobAsync(j, "req")
  Wait For (req) req_Result(res As DBResult)
 'work with result
 req.PrintTable(res)
 Table.SetData(req.Rows) 'this will work if the data is formatted exactly as you want it to be displayed.
 'another option which is relevant when you need to further process the data before it is displayed:
  Dim data As List
 data.Initialize
  For Each row() As Object In res.Rows
    Dim val1 As String = row(res.Columns.Get("animal"))
    Dim val2 As Int = row(res.Columns.Get("age"))
    data.Add(Array(val1, val2)
 Next
 Table.SetData(data)
 
Upvote 1
Top