Android Question SQLite check result exist?

tsteward

Well-Known Member
Licensed User
Longtime User
Probably very simple but I may have confused myself.
I'm going through my app trying to make it more crash resistant. Can I / should I check there are rows to process before processing them and how?
Attached is sample code. How do I detect No results. B4A and B4i please.

B4X:
Dim rsData As ResultSet = Main.sql1.ExecQuery2($"SELECT * FROM table WHERE ID = ?"$, Array As String(myID))
    Do While rsData.NextRow
    .....
    Loop
    rsData.close
'I want to pop up a message if there are no results'
 

MicroDrie

Well-Known Member
Licensed User
Longtime User
You can perhaps use the sqlite count query first:
Retrieve select count:
SELECT count(TableColumn) FROM Table
and test if the result is greater then zero.
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I can't use that in B4i :(
>Dim rsData As ResultSet
>If rsData.RowCount > 0 Then
>I can't use that in B4i

Is that really so?
Are you not confusing this with Cursor?
I hope it is not true as I use this a lot in B4A and have plans to eventually convert to B4i.

RBS
 
Upvote 0
Top