Android Question Sqlite with Select query

Sreenadh OG

Member
Licensed User
Longtime User
hai all,
I have a database contain id, name, phone, address, email. Now i want to get only name from this table.
My query is ..SELECT * FROM tbl_address WHERE id='" & txt_Id.Text & "'
 

derez

Expert
Licensed User
Longtime User
B4X:
Dim cur As Cursor
If txt_id <> "" Then
    cur = SQL.ExecQuery2("SELECT Name FROM tbl_address WHERE Id = ?", Array As String(txt_Id.Text))
    cur.Position = 0
    Return cur.GetString("Name")
end if
 
Upvote 0

Sreenadh OG

Member
Licensed User
Longtime User
hi,
I am getting error in following code..I want to use two cursor in one event..
B4X:
Sub btnAddList_Click
   Dim cur As Cursor
   Dim cusrsExist As Cursor
   
     Dim getItem As String
     Dim list_add As List
     Dim listId As Int
     list_add.Initialize
     cur=Calculation.Sqlcnn.ExecQuery("Select reason from tbl_reason")  
     For i=0 To cur.RowCount-1
       cur.Position=i
       list_add.Add(cur.GetString("reason"))
     Next   
     cur.Close
     listId=InputList(list_add,"Select An Item",1)
     getItem=list_add.get(listId)
cusrsExist = Calculation.Sqlcnn.ExecQuery2("SELECT items FROM tbl_listing WHERE items = ?", Array As String(getItem))
            cusrsExist.Position=0
            Dim strExist As String
            strExist= cusrsExist.GetString("items") ' Error:CursorIndex OutofBountException
            If strExist = "" Then
                Calculation.Sqlcnn.ExecNonQuery2("insert into tbl_listing(items)values(?)",Array As String(getItem))  
            End If
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4X:
  cusrsExist = Calculation.Sqlcnn.ExecQuery2("SELECT items FROM tbl_listing WHERE items = ?", ArrayAsString(getItem))
      if cusrsExist.RowCount > 0 then
      cusrsExist.Position=0
      [..]
 
Upvote 0
Top