Android Question DBUtils ExecuteMap problem

hatzisn

Well-Known Member
Licensed User
Longtime User
Hi everyone,

I discovered a minor bug in the new DBUtils ExecuteMap Sub that can lead to a disaster. If you submit some StringArgs() to the sub that do not return any results there was a problem as the res.Initialize was where you see it as "Old Position". When there was not a single result the map was returning uninitialized. Correct it everyone if you have not done so already. When it is located in "New Position" everything works perfectly.


B4X:
Public Sub ExecuteMap(SQL As SQL, Query As String, StringArgs() As String) As Map
    Dim res As Map
'********** New position ***********
    res.Initialize
'********************************
    Dim cur As ResultSet
    If StringArgs <> Null Then
        cur = SQL.ExecQuery2(Query, StringArgs)
    Else
        cur = SQL.ExecQuery(Query)
    End If
    Log("ExecuteMap: " & Query)
    If cur.NextRow = False Then
        Log("No records found.")
        Return res
    End If
'********** Old position ***********
'    res.Initialize
'********************************
    For i = 0 To cur.ColumnCount - 1
        res.Put(cur.GetColumnName(i).ToLowerCase, cur.GetString2(i))
    Next
    cur.Close
    Return res
End Sub

Cheers
 

hatzisn

Well-Known Member
Licensed User
Longtime User
Oh, I see. So it returns an uninitialized map and you have to check the map.IsInitialized property...
I did not see that...
 
Upvote 0
Top