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
b="Horse of a different color"
cur1 = SQL1.ExecQuery2("SELECT * FROM idom WHERE name = ?" ,Array As String(b)) '?? table name = idom / ido
Log (cur1.RowCount)
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
log(cur1.GetString("name")) '?? there is a Column / field = "text" or "name"
Next
b="Horse of a different color"
cur1 = SQL1.ExecQuery2("SELECT * FROM idom WHERE name = ?" ,Array As String(b)) '?? table name = idom / ido
Log (cur1.RowCount)
For i = 0 To Cursor1.RowCount - 1
Cursor1.Position = i
log(cur1.GetString("name")) '?? there is a Column / field = "text" or "name"
Next
Dim b as string ="Horse of a different color"
cur1 = SQL1.ExecQuery2("SELECT * FROM idom WHERE name = ?" ,Array As String(b))
Log (cur1.RowCount) 'Should = 2
For i = 0 To cur1.RowCount - 1
cur1.Position = i
Log(cur1.GetString("text"))
Next
Dim b as string ="Horse of a different color"
cur1 = SQL1.ExecQuery2("SELECT * FROM idom WHERE name = ?" ,Array As String(b))
Log (cur1.RowCount) 'Should = 2
For i = 0 To cur1.RowCount - 1
cur1.Position = i
Log(cur1.GetString("text"))
Next