B4J Question B4XTable not show anything in B4J

makis_best

Well-Known Member
Licensed User
Longtime User
Hi

I have a very simple app that load some data from one MSSQL database using JRDC2.
But I have a problem I don't understand why happening.
B4XTable not show any record. The application run without error Log full of records but nothing on B4XTable.
Need to tell also that I don't get any error and req.PrintTable(res) show my records on log correct.
The code I use is
B4X:
Sub GetRecord (info As Map)
    Dim Data As List
    Data.Initialize
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("Select_Recs", Array(info.Get("FromDate"), info.Get("ToDate")))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        For Each row() As Object In res.Rows
            DateTime.DateFormat = "yyyy-MM-dd"
            DateTime.TimeFormat = "HH:mm:ss"
            Dim Dm2, Dm6 As String
            Dm2 = DateTime.Date(row(2)) & " " & DateTime.Time(row(2))
            Dm6 = DateTime.Date(row(6)) & " " & DateTime.Time(row(6))
            Data.Add(Array As Object(row(13), Dm2, row(1), Dm2, row(3), row(4), row(5), Dm6, row(7), row(8), row(9), row(10), row(11), row(12), row(14), row(15)))
        Next
        Log("========= Size: " & Data.Size)  ----> Return ========= Size: 80
        req.PrintTable(res)
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
    B4XTable1.SetData(Data)
End Sub

Any help?

Thank you.
 

agraham

Expert
Licensed User
Longtime User
Probably because SetData is an asynchronous operation.
 
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
I don't think so.
I use the same code and others apps and work fine.
Something else must be
 
Upvote 0

makis_best

Well-Known Member
Licensed User
Longtime User
Is there any problem to call B4XTable inside a class?
Feel the table inside the class?
Stupid question....
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Just to test, from an old app I have where this is working, try this way, if it works, then you can later try to set de dates, etc... (it's almost your same code)

B4X:
Sub GetRecord (info As Map)
    Dim Data As List
    Data.Initialize
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("Select_Recs", Array(info.Get("FromDate"), info.Get("ToDate")))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        'Changed code
        Dim SingleRecord As List
        
        For Each row() As Object In res.Rows
            SingleRecord.Initialize
            For Each record As Object In row
                SingleRecord.Add(record)
            Next
            Data.Add(SingleRecord )
        Next
        'End Changed Code
        Log("========= Size: " & Data.Size)  ----> Return ========= Size: 80
        req.PrintTable(res)
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
    B4XTable1.SetData(Data)
End Sub
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…