I keep getting an error that table 'scoring' doesn't exist. The database wasn't being created so I created one with an SQLLite studio and added it to the files tab, but still no success.
MAIN ACTIVITY:
In an activity named 'Page_Scoring' I have a 'Save' button to insert data from views into the table 'scoring', this is where it fails saying there is no table called 'scoring.'.
Any help appreciated.
Many Thanks
P
MAIN ACTIVITY:
B4X:
Sub Process_Globals
Dim DS_SQL1 As SQL
End Sub
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
'Check if database exists
If File.Exists(File.DirAssets, "dartsmart.db") = False Then
'copy the default DB
File.Copy(File.DirAssets, "dartsmart.db", File.DirInternal, "dartsmart.db")
'if not, initialise it
DS_SQL1.Initialize(File.DirInternal, "dartsmart.db", True)
'and then create the database tables
CreateDatabaseTables
'copy the default DB
File.Copy(File.DirAssets, "dartsmart.db", File.DirInternal, "dartsmart.db")
Else
'initialise it
DS_SQL1.Initialize(File.DirInternal, "dartsmart.db", True)
End If
End If
'Load Layout
Activity.LoadLayout("lay_Home")
End Sub
B4X:
Sub CreateDatabaseTables
Dim CRE_Scoring As String
CRE_Scoring = "CREATE TABLE IF NOT EXISTS scoring (ID INTEGER PRIMARY KEY,Visits TEXT, Ave TEXT, Points TEXT)"
DS_SQL1.ExecNonQuery(CRE_Scoring)
End Sub
B4X:
Sub btn_Scoring_Click
'Load Layout/Activity
StartActivity(Page_Scoring)
End Sub
In an activity named 'Page_Scoring' I have a 'Save' button to insert data from views into the table 'scoring', this is where it fails saying there is no table called 'scoring.'.
B4X:
Sub btn_SaveGame_Click
Dim INS_scoring As String
INS_scoring = "INSERT INTO scoring VALUES (NULL, ?, ?, ?)"
Main.DS_SQL1.ExecNonQuery2(INS_scoring, Array As String( lbl_Visits.Text, lbl_3DA.Text, lbl_Total.text))
End Sub
Any help appreciated.
Many Thanks
P