Android Question call JRDC2 wait for

Discussion in 'Android Questions' started by astronald, May 9, 2019.

  1. astronald

    astronald Member Licensed User

    How i can call jrdc2 with wait for

    i try this but dont work.

    Code:
    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.
     
  2. DonManfred

    DonManfred Expert Licensed User

    Code:
    Dim req As DBRequestManager = CreateRequest
       
    Dim cmd As DBCommand = CreateCommand("select_animal"Array(id))
       
    Wait For (req.ExecuteQuery(cmd, 0Null)) 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
     
    BillMeyer, José J. Aguilar and Erel like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice