Hi folks, my first steps into SQLlight via DBUtils. Fighting since hours with a strange thing. Following User's Guide Chapters 3 & 4 I managed to create a db-file on SD-card into a folder created by my application. So far so good. Currently I have no viewer tryed for the database itself, so I am simply checking the size of the database after putting the first record into it. No error when compiling or during runtime raises up. Only the time of change of the databasefile is corresponding to the moment when my application puts the data into the DB. Filesize is exactly the same after putting a record into the database and this is telling me that the record was not written into the DB.
Maybe I forgot a variable to declare, but in this case the application would not run, all variables are declared in Process Globals:
So the creation of the database is done within the same activity with the following code and runs fine. It's within a loop, deciding to put it to internal storage or to external SD-Card and if it's already exist, not to touch it.
Then application starts and raises a panel from time to time, forcing the user to input data. After giving an OK-button a go, the following routine should save the users input into the database then
So, in my thinking, if there would be a conflict with the predefined format of my database, during runtime I would get an error. Wrong syntax, the compiler would complain. But when giving the routine a run, the panel is closing, the input-data went to Nirvana... Any idea?
Maybe I forgot a variable to declare, but in this case the application would not run, all variables are declared in Process Globals:
Dim SQL1 As SQL
Dim ID As Int
Dim DBDirName As String
Dim DBFileName As String
Dim DBTableName1 As String
So the creation of the database is done within the same activity with the following code and runs fine. It's within a loop, deciding to put it to internal storage or to external SD-Card and if it's already exist, not to touch it.
Sub Activity_Create(FirstTime As Boolean)
DBFileName = "My Database.db"
If File.ExternalWritable=True Then
If File.IsDirectory(File.DirRootExternal,"Own Database/") = False Then
File.MakeDir(File.DirRootExternal,"Own Database/")
End If
DBDirName = File.DirRootExternal & "/Own Database"
Else
If File.IsDirectory(File.DirInternal,"Own Database/") = False Then
File.MakeDir(File.DirInternal, "Own Database/")
End If
DBDirName = File.DirInternal & "/Own Database"
End If
If FirstTime Then
SQL1.Initialize(DBDirName,DBFileName, True)
Dim M As Map
M.Initialize
M.Put("ID", DBUtils.DB_INTEGER)
M.Put("Text1", DBUtils.DB_TEXT)
M.Put("Text2", DBUtils.DB_TEXT)
M.Put("Text3", DBUtils.DB_TEXT)
M.Put("Text4", DBUtils.DB_TEXT)
M.Put("Text5", DBUtils.DB_TEXT)
M.Put("Text6", DBUtils.DB_TEXT)
M.Put("Text7", DBUtils.DB_TEXT)
M.Put("Text8", DBUtils.DB_TEXT)
M.Put("Timestamp", DBUtils.DB_TEXT)
DBUtils.CreateTable(SQL1, DBTableName1, M, "ID")
End If
Activity.LoadLayout ("MainLayout")
Activity.Title = ProgName & ProgVersion
End Sub
Then application starts and raises a panel from time to time, forcing the user to input data. After giving an OK-button a go, the following routine should save the users input into the database then
Sub BAddRecord_Click
Dim Maps As List
Dim MP As Map
Maps.Initialize
MP.Initialize
MP.Put("ID",Null)
MP.Put("Text1",Label1.Text)
MP.Put("Text2",Label2.Text)
MP.Put("Text3",AutoCompleteEditText1.Text)
MP.Put("Text4",AutoCompleteEditText2.Text)
MP.Put("Text5",AutoCompleteEditText3.Text)
MP.Put("Text6",AutoCompleteEditText4.Text)
MP.Put("Text7",AutoCompleteEditText5.Text)
MP.Put("Text8",AutoCompleteEditText6.Text)
Dim Now As Long
Now = DateTime.Now
MP.Put("Timestamp",DateTime.Date(Now) & " - " & DateTime.Time(Now))
Maps.Add(MP)
DBUtils.InsertMaps(SQL1,DBTableName1,Maps)
PAddRecord.Visible = False 'Hides the Input-Panel
End Sub
So, in my thinking, if there would be a conflict with the predefined format of my database, during runtime I would get an error. Wrong syntax, the compiler would complain. But when giving the routine a run, the panel is closing, the input-data went to Nirvana... Any idea?