Android Question Error in parameter Sql query

omidaghakhani1368

Well-Known Member
Licensed User
Hi.
I use below code for get row count but get error
sql1.ExecQuerySingleResult2("SELECT COUNT(*) FROM tbl_friends WHERE sID ='?'",Array As String(user_id)) = 0 Then

error : android.database.sqlite.SQLiteBindOrColumnIndexOutOfRangeException: bind or column index out of range: handle 0x149eb8
 

Pendrush

Well-Known Member
Licensed User
B4X:
sql1.ExecQuerySingleResult2("SELECT COUNT(*) FROM tbl_friends WHERE sID=?",Array As String(user_id)) = 0 Then
remove ' before and after ?
 

mangojack

Well-Known Member
Licensed User
maybe
B4X:
Dim rowCount As Int = sql1.ExecQuerySingleResult2("SELECT COUNT(*) FROM tbl_friends WHERE sID=?",Array As String(user_id))
If rowCount = 0 Then
 

sorex

Expert
Licensed User
I'm not 100% sure about SQLite but I believe it's always text but it detects on the content if it is a number, date, datetime or real string field.
 

omidaghakhani1368

Well-Known Member
Licensed User
I'm not 100% sure about SQLite but I believe it's always text but it detects on the content if it is a number, date, datetime or real string field.
use quote according to field's type In all databases(mssql,mysql,sqlite and ...) is same.
just when use prepare parameter in b4a is problem
 
Top