vb4android

How to solve "object converted to string" error in B4A


Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Type DBResult (Tag As Object, **Columns As Map**, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)
Private const rdcLink As String = "http://192.168.8.100:17178/rdc"
End Sub

This is the methods for process globals . Here columns As Map is initialized . However the line bolded in the below code gives an error as , "Object converted to String. This is probably a programming mistake. (warning #7)"

Sub GetRecord
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("selectAllNames", Null)
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)
    'work with result
    'req.PrintTable(res)
    ***Log(res.Columns)***
    ListViewListTable.Clear
    For Each row() As Object In res.Rows
        Dim oBitMap As Bitmap
        Dim buffer() As Byte
        buffer = row(res.Columns.Get("gambar"))
        oBitMap = req.BytesToImage(buffer)
        ListViewListTable.AddTwoLinesAndBitmap(row(1), "See more...", oBitMap)
    Next
Else
    Log("ERROR: " & j.ErrorMessage)
End If
j.Release
End Sub

So what should I do to remove the error?


Solution

  • If columns is a map? (which it looks to be?).

    Then to display the columns you can use this:

    For Each MyKey As String in res.Columns.Keys
       log("Key name = " & MyKey)
       log("Key value = " & res.Columns.Get(MyKey))
    Next