Android Question Error in parameter Sql query

omidaghakhani1368

Well-Known Member
Licensed User
Longtime 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
Longtime User
B4X:
sql1.ExecQuerySingleResult2("SELECT COUNT(*) FROM tbl_friends WHERE sID=?",Array As String(user_id)) = 0 Then

remove ' before and after ?
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

sorex

Expert
Licensed User
Longtime 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.
 
Upvote 0

omidaghakhani1368

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
use quote according to field's type In all databases(mssql,mysql,sqlite and ...) is same.

with the exeption that SQLite only has text field types even when you select date or anything else in an sqlite editor.
 
Upvote 0
Top