Sqlitte Multiple 'like' Query Problem

mc73

Well-Known Member
Licensed User
Longtime User
Dear all,

writing

B4X:
CursorSearch = sql1.ExecQuery2("SELECT ID FROM items WHERE (DESCRIPTION LIKE ? OR DESCRIPTION LIKE ?) AND ID>=10000 AND ID<20000", Array As Object(mySearch,mySearch2))

returns a 'ClassCastException'.

But when I write:

B4X:
CursorSearch = sql1.ExecQuery("SELECT ID FROM items WHERE (DESCRIPTION LIKE '" & mySearch & "' OR DESCRIPTION LIKE '" & mySearch2 & "') AND ID>=10000 AND ID<20000")

it works as it should. 'mySearch' and 'mySearch2' are dimmed as strings.

Any ideas what goes wrong with my first line? Thank you.
 

edgar_ortiz

Active Member
Licensed User
Longtime User
ExecQuery2 needs a array of strings.

Dear all,

writing

B4X:
CursorSearch = sql1.ExecQuery2("SELECT ID FROM items WHERE (DESCRIPTION LIKE ? OR DESCRIPTION LIKE ?) AND ID>=10000 AND ID<20000", Array As Object(mySearch,mySearch2))

returns a 'ClassCastException'.

But when I write:

B4X:
CursorSearch = sql1.ExecQuery("SELECT ID FROM items WHERE (DESCRIPTION LIKE '" & mySearch & "' OR DESCRIPTION LIKE '" & mySearch2 & "') AND ID>=10000 AND ID<20000")

it works as it should. 'mySearch' and 'mySearch2' are dimmed as strings.

Any ideas what goes wrong with my first line? Thank you.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Thank you!
I've checked all other statements in my code, I use 'array as string'. The reason I got confused was that I found one execNonQuery statement where I used 'array as string' instead of 'array as object; so I thought it wouldn't make a difference :)
 
Upvote 0
Top