Android Question call JRDC2 wait for

astronald

Member
Licensed User
How i can call jrdc2 with wait for

i try this but dont work.

B4X:
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "select"
    cmd.Parameters = Array()
    Dim ser As B4XSerializator
    Dim data() As Byte = ser.ConvertObjectToBytes(CreateMap("command": cmd, "limit": 0,  "version": 2))

 Private j As HttpJob
   
    Try
        j.Initialize("",Me)
        j.PostBytes(rdcLink & "?method=query2" , data)

        Wait For (j) JobDone(j As HttpJob)
        If j.Success Then
            Dim data() As Byte = Bit.InputStreamToBytes(j.GetInputStream)
            Dim res As DBResult = ser.ConvertBytesToObject(data)

            Return res
        Else
           
        End If
    Catch
       
    End Try
   
    If j.IsInitialized Then  j.Release
    Return res
Thanks.
 

DonManfred

Expert
Licensed User
B4X:
 Dim req As DBRequestManager = CreateRequest
   Dim cmd As DBCommand = CreateCommand("select_animal", Array(id))
   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)
   Else
       Log("ERROR: " & j.ErrorMessage)
   End If
   j.Release
 
Top