Android Question Check for NULL in RDC Result

Declan

Well-Known Member
Licensed User
Longtime User
I am using the following code to check if a record "deviceid" exists in the mySQL database table on my server:
B4X:
Sub GetRecord (id As String)
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("check_device", 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)

        For Each row() As Object In res.Rows
        
            If row(res.Columns.Get("deviceid")) <> Null Then
                Log("Got Device")
            End If
            If row(res.Columns.Get("deviceid")) = Null Then
                Log("Got NO Device")
            End If
            
        Next
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
End Sub
The above code gives me the Log("Got Device") when result is ok and a deviceid is returned.
However if NO device is returned in the result, I do not get Log("Got NO Device").
Can anyone point as to what I am doing incorrectly.
 

OliverA

Expert
Licensed User
Longtime User
res.Rows is a List. If jRDC returns no results after running a query successfully, res.Rows.Size = 0
 
Upvote 1
Cookies are required to use this site. You must accept them to continue using the site. Learn more…