Sub UserLogin As ResumableSub
Try
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("pLogin", Array(EditText1.Text, EditText2.Text))
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)
If res.Rows.Size = 0 Then
MsgboxAsync("Invalid user credentials, please try again", "Error")
Wait For Msgbox_Result
Return False
Else
For Each row() As Object In res.Rows
Variables.Name = row(res.Columns.Get("firstname")) & " " & row(res.Columns.Get("lastname"))
Next
Return True
End If
Else
MsgboxAsync("Cannot connect to the server, please check your internet connection and try again.", "Error")
Wait For Msgbox_Result
Log("ERROR: " & j.ErrorMessage)
Return False
End If
j.Release
Catch
MsgboxAsync("An error occurred, please try again later.", "Error")
Wait For Msgbox_Result
Log(LastException)
Return False
End Try
End Sub