Android Question what's wrong with this sql command

tsteward

Well-Known Member
Licensed User
Longtime User
if non parametrised this works but how do I get it to work in parametrised version please.
I get error java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0

Non Parametrised:
Dim cmrs As ResultSet = Main.sql1.ExecQuery($"SELECT * FROM Vehicles WHERE Model LIKE '%${data}%' order by Model"$

Parametrised:
Dim cmrs As ResultSet = Main.sql1.ExecQuery2($"SELECT * FROM Vehicles WHERE Model LIKE '%?%' order by Model"$, Array As String(data))
 

JohnC

Expert
Licensed User
Longtime User
The first one has three "$" - unbalanced.
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
It should be:
B4X:
Dim cmrs As ResultSet = SQL.ExecQuery2($"SELECT * FROM Vehicles WHERE Model LIKE ? order by Model"$, Array As String($"%${data}%"$))
Thank you. I actually walked away to make some brekky and thought of the same thing. Sometimes the obvious is not so obvious to me. I'm a great tradie but a hacker of a programmer Ha Ha Ha
 
Upvote 0
Top