Android Question problem with sqlite

Kwong

Member
Licensed User
Longtime User
I am a newbie here, trying to have a simple code to manipulate data with the sqlite database. But I got an error on line 110. this exercise is mainly copy from my reference book of b4a. Only different with the table structure. thank you very much for your help.

regards,
Kwong
 

Attachments

  • sqltest.zip
    14.1 KB · Views: 97

mangojack

Well-Known Member
Licensed User
Longtime User
Sub queryDB contained no SQL query string
In Button5 Click all you attempt to do is pass the contents of edtSQL.Text as the Query.

B4X:
Sub Button5_click
   queryDB(edtSQL.text)
End Sub

Sub queryDB(strSQL As String)
  lsvOutput.Clear()

  '@@  Added Query ... Edit to suit !
  Dim query As String
  query = "SELECT * FROM log WHERE myField = ?"

  Cursor1 = SQL1.ExecQuery2(strSQL,Array As String(strSQL))
  '..............

* Also .. edtSQL is not present in layout 'Main' .. you have declared it in globals but not initialized it (error Raised)
** check button4 query ... FORM > FROM

*** a suggestion .. It might be wise to rename your buttons to something more meaningful ..
 
Last edited:
Upvote 0

Kwong

Member
Licensed User
Longtime User
Sub queryDB contained no SQL query string
In Button5 Click all you attempt to do is pass the contents of edtSQL.Text as the Query.

B4X:
Sub Button5_click
   queryDB(edtSQL.text)
End Sub

Sub queryDB(strSQL As String)
  lsvOutput.Clear()

  '@@  Added Query ... Edit to suit !
  Dim query As String
  query = "SELECT * FROM log WHERE myField = ?"

  Cursor1 = SQL1.ExecQuery2(strSQL,Array As String(strSQL))
  '..............

* Also .. edtSQL is not present in layout 'Main' .. you have declared it in globals but not initialized it (error Raised)
** check button4 query ... FORM > FROM

*** a suggestion .. It might be wise to rename your buttons to something more meaningful ..
thank you, jack. may amend the code and try again. will let you know how it go later. thank you very much
 
Upvote 0

Kwong

Member
Licensed User
Longtime User
Happy New Year to all of you. Return from my long vocation.

Because I'm new with VB and B4A, I don't really understand every lines you guys modified for me. So, I modified my code according to my reference and hopefully learn from it by the mistakes. According to advice from Jack, I modified those buttons to something meaningful. Now, the code running better without hitting any of the design buttons. Will keep going and try again. Thank you again for all of your help.
 
Upvote 0
Top