Android Question How to SELECT Data from Search View

apiwatcomscith

Member
Licensed User
Longtime User
Hello guys .
I'm using a Search View for Search a terminology in database it success complete but I can't "SELECT * FROM table_eng2thai WHERE eng=" & Value (as string) this command for select translate word to show on the label.text or another in new Activity,
B4X:
Sub sv_ItemClick (Value As String)

    'Msgbox(Value,"TEST")
    Dim row As Int
    Dim  Cursor1 As Cursor
   
    getValue = Value
   
    ID.Initialize
   
    Cursor1 = sql1.ExecQuery("SELECT * FROM eng2thai WHERE esearch = "&Value)
    'Msgbox (Cursor1.GetString("esearch"), "test")
   
    If Cursor1.RowCount > 0 Then
        RowNumber = Cursor1.RowCount
        ID.Initialize
        For row = 0 To RowNumber - 1
            Cursor1.Position = row
            ID.Add(Cursor1.GetInt("id"))
        Next
    End If
   
    Cursor1.Close
   
    StartActivity("Detail")
End Sub
I'm very try again but it not work .

thank you and sorry I'm speak English not good.
 

mangojack

Expert
Licensed User
Longtime User
Try this ..
B4X:
Dim query As String
query = "SELECT * FROM eng2thai WHERE eng = ?"
Cursor1 = SQL1.ExecQuery2(query, Array As String(Value))  ' ** ExecQuery2 **
 
Upvote 0

apiwatcomscith

Member
Licensed User
Longtime User
Try this ..
B4X:
Dim query As String
query = "SELECT * FROM eng2thai WHERE eng = ?"
Cursor1 = SQL1.ExecQuery2(query, Array As String(Value))  ' ** ExecQuery2 **
Hi ,mangojack This you code it work but will be add this line cursor1.position = 0
I'm very happy ,Thank you very much.
 
Upvote 0
Top