iOS Question [B4X] DBRequestManager - getting different results with B4i than B4A/B4J

MrKim

Well-Known Member
Licensed User
Longtime User
EDIT: I solved this by changing ColNames(X) = Col to ColNames(Res.Columns.Get(Col)) = Col.
But I still feel something must be wrong given that the data returned by each program is in such a radically different format.


I am feeling a little gun shy about posting so many of my posts lately seem to have been stupid mistakes on my part or a lack of understanding .. BUT here we go again.

I am using DBRequestManager.bas

I am running the exact same code in A/J/i
The relevant code:
B4X:
    'SELECT Emp_Num, Emp_FirstName, Emp_LastName, Emp_AllowEdits, Emp_Rate, Emp_AllowMulti FROM Employees WHERE (Emp_Inactive=0);
    Dim req As DBRequestManager = CreateRequest
    Dim cmd1 As DBCommand = CreateCommand("GetEmployees", Null)
    Wait For (req.ExecuteQuery(cmd1, 0, "GetEmployees")) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        If res.Rows.Size > 0 Then
            EMPs = req.DBResultToMap(res)
        Else
.
.
Sub DBResultToMap(Res As DBResult) As List
    Dim ColNames(Res.Columns.Size) As String, X As Int
    For Each Col In Res.Columns.Keys
        ColNames(X) = Col
        X = X + 1
    Next

    Dim Rows As List, X As Int, Y As Int
    Rows.Initialize
    For Each Row() As Object In Res.Rows
        X = 0
        Dim Cols As Map
        Cols.Initialize
        Y = 0
        For Each Fld As String In Row
            Cols.Put(ColNames(Y), Fld)
            Y = Y + 1
        Next
        Rows.Add(Cols)
    Next
    Return Rows
End Sub
The problem is this: in B4i the fields are returned in a different order plus size gets added as a bonus field. The data does not. So when my little routine to put stuff in a map is done everything is in the wrong field in B4i. DBResultToMap is meant to be generic so regardless of the data passed it should return a map with everything in the right fields.

DBResultToMap:
1625835397521.png

1625835579430.png


res looks completely different in B4i compared toB4j (and I am assuming B4A, I didn't check B4A but it works)
1625835768658.png


1625835803244.png


What silly mistake am I making this time? Or do I need to handle B4i data differently?

Thanks in advance for your help.
 

MrKim

Well-Known Member
Licensed User
Longtime User
You are keep making claims that are plainly wrong.
I cannot help you like this. Sorry.
I was not implying that there is something wrong with B4x. I was trying to say that I feel like, once again, I am looking at something the wrong way.
 
Upvote 0
Top