简体   繁体   English

如何解决 B4A 中的“对象转换为字符串”错误

[英]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.这里列 As Map被初始化。 However the line bolded in the below code gives an error as, "Object converted to String. This is probably a programming mistake. (warning #7)"然而,下面代码中加粗的行给出了一个错误,“对象转换为字符串。这可能是一个编程错误。(警告 #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?那么我应该怎么做才能消除错误呢?

If columns is a map?如果列是 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM