I am using the following code to check if a record "deviceid" exists in the mySQL database table on my server:
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.
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
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.