All,
I just started to experiment with SQL in B4A
Based on one of the examples in the B4A documentation, I have a very simple test program that writes one record to an SQL table and then reads this one record. This simple program works nicely. Here is the code.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
‘ Write one record to a database table and then read it and display it
Dim SQL1 As SQL
Dim Cursor1 As Cursor
SQL1.Initialize(File.DirDefaultExternal, "test1.db", True)
SQL1.ExecNonQuery("Drop Table if Exists Table1")
SQL1.ExecNonQuery("Create Table Table1 (Column1 Text)")
SQL1.ExecNonQuery("INSERT INTO Table1 Values ('Test Record 1')")
Cursor1 = SQL1.ExecQuery("Select Column1 from Table1")
Cursor1.Position = 0
Msgbox (Cursor1.GetString("Column1"),"Record from Database")
Cursor1.Close
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
I then wrote a second very small program to simply read the one record that the first program wrote to the database. When I run this program I receive this error message in the log file “android.database.sqlite.SQLiteException: no such table: Table1: , while compiling: Select Column1 from Table1”
The code for this second program is shown below. I must be missing something. I have looked at other examples in the documentation, but I have not been able to find the missing piece.
Thanks for your assistance.
Brad
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
‘ Obtain a single record from a database table that was added by another program
Dim SQL1 As SQL
Dim Cursor1 As Cursor
SQL1.Initialize(File.DirDefaultExternal, "test1.db", True)
Cursor1 = SQL1.ExecQuery("Select Column1 from Table1")
Cursor1.Position = 0
Msgbox (Cursor1.GetString("Column1"),"Record from Database")
Cursor1.Close
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
I just started to experiment with SQL in B4A
Based on one of the examples in the B4A documentation, I have a very simple test program that writes one record to an SQL table and then reads this one record. This simple program works nicely. Here is the code.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
‘ Write one record to a database table and then read it and display it
Dim SQL1 As SQL
Dim Cursor1 As Cursor
SQL1.Initialize(File.DirDefaultExternal, "test1.db", True)
SQL1.ExecNonQuery("Drop Table if Exists Table1")
SQL1.ExecNonQuery("Create Table Table1 (Column1 Text)")
SQL1.ExecNonQuery("INSERT INTO Table1 Values ('Test Record 1')")
Cursor1 = SQL1.ExecQuery("Select Column1 from Table1")
Cursor1.Position = 0
Msgbox (Cursor1.GetString("Column1"),"Record from Database")
Cursor1.Close
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
I then wrote a second very small program to simply read the one record that the first program wrote to the database. When I run this program I receive this error message in the log file “android.database.sqlite.SQLiteException: no such table: Table1: , while compiling: Select Column1 from Table1”
The code for this second program is shown below. I must be missing something. I have looked at other examples in the documentation, but I have not been able to find the missing piece.
Thanks for your assistance.
Brad
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
‘ Obtain a single record from a database table that was added by another program
Dim SQL1 As SQL
Dim Cursor1 As Cursor
SQL1.Initialize(File.DirDefaultExternal, "test1.db", True)
Cursor1 = SQL1.ExecQuery("Select Column1 from Table1")
Cursor1.Position = 0
Msgbox (Cursor1.GetString("Column1"),"Record from Database")
Cursor1.Close
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~