Both store data tinto the .sqlite file (it seems); my Display window shows those data into its ListBox, but when I quit the application / run back, these records disappears.
I followed the “App.Open” Event (where the app working folder is created… and nothing weird happens.
I locked the .sqlite file there, run and no complains…
It looks like if the data base file is a ghost; I looked at the wDisplay file code that add the data into the ListBox, and the FolderItem for the .sqlite file (used in that code) shows the file where I think it is.
I am starting to be wonky…
M1 MacBook Pro
Xojo 2021r2.1
Monterey 12.6
The batch Import uses
INSERT INTO Books("<list of columns>") "VALUES (?, ?, ?, ?, ?, ?)"
I just checked if there is a FolderItem passed to App.gDB.DatabaseFile, and there is one.
I add:
System.DebugLog App.gDB.DatabaseFile.NativePath
After the Commit line and I get the lines (in the batch import) with the path of the .sqlite file; but that file modification date does not change (nearly 3 hours ago) and its size is still 8192 Bytes.
hmm, try to separate it,
close other db designer tools.
xojo, open db instacne with folder item, connect, execute a simple insert statement in one method.
The answer was simple: the database was created in memory.
The error was probably a wrong line of code order…
DB.DatabaseFile = f
was certainly not were it belong.
I’ve done so many changes that I cannot be certain, and the culprit was when I coded the read from the .sqlite file using API1 and “direct” code (in the display window, I opened the .sqlite file and open it from that FolderItem / API1 db code to read its contents).
I was certainly tired, but once I was back home, I wrote new read code and that was clear to me where to search.
i usually sub class this database and it looks like:
Public Sub Constructor()
// Calling the overridden superclass constructor.
Super.Constructor
Self.DatabaseFile = File()
Self.Connect
End Sub
Public Sub Destructor()
Self.Close
End Sub
Public Function File() As FolderItem
Var f As FolderItem = SpecialFolder.Documents.Child("Database").Child("SomeDB.Xojo.sqlite")
System.DebugLog f.NativePath
Return f
End Function
In App.Open, I call methods that creates a folder for the application in the ApplicationSupport folder and creates the Data Base file / add TABLE(s), and store the References in App Properties.
Then in Modules, I place code to Add Record, Import from txt, Modify, Delete, Export, Display, etc…