B4J Question non Async Single Query Result

atiaust

Active Member
Licensed User
Longtime User
Hi All,

I have a problem with a Mysql query and was wondering if anyone may know how to use a 'Wait For' with a non Acync Single Result Query.
I believe my code is moving on before I get a valid result from the query so the 'If Then' is always processed.

B4X:
Dim result as Int = 0
 result = Sql.ExecQuerySingleResult2("SELECT count(*) FROM trip WHERE tripDate = ? AND tripType = ?",Array As String(searchDate &"%","D"))
'
If result = 0 then
     do something ....
End If

Thanks
 

OliverA

Expert
Licensed User
Longtime User
It's not going to work for non-async methods of the SQL library. You could switch to using the ExecQueryAsync method. You then have to get the result from the result set instead directly from the method. A little bit more work, but this may be worth it if you need to process the query asynchronously.
 
Upvote 0

atiaust

Active Member
Licensed User
Longtime User
Thank you both for your reply.

I wasn't sure if ExecQuerySingleResult was syncronus or asyncronus.

There may be a problem in the Query that I need to resolve.
 
Upvote 0
Top