Android Question sqlite read data from database

hamedaz

Member
Hi you dear friends
I've written this code. I want to get information from the database based on the following conditions. But I am faced with the following error message.

android.database.sqlite.SQLiteException: near "of": syntax error (code 1): , while compiling: SELECT * FROM idom WHERE name=Horse of a different color

B4X:
b="Horse of a different color"
cur1=sql1.ExecQuery("SELECT * FROM idom WHERE name="&b)
For i=0 To cur1.RowCount -1
lbl.Initialize("")
        'lbl.Gravity=Gravity.CENTER_HORIZONTAL
        lbl.Gravity= Bit.Or(Gravity.CENTER_HORIZONTAL,Gravity.FILL)

        lbl.TextSize=20
        lbl.TextColor=Colors.Black
        lbl.Text=cur1.GetString("text")
next
 

hamedaz

Member
Hi Hamedaz.

The problem is with your database file. It contains two carriage returns after the text, and therefore is not an exact match for your search text.

Try the corrected database attached, or change your code to:

B4X:
b = "%Horse of a different color%"
cur1=sql1.ExecQuery2("SELECT * FROM idom WHERE name Like ?", Array As String(b))



View attachment 44742
Thank you very much dear friend and other friends have helped me a lot
 
Upvote 0
Top