When I run the app, it is open a dialog to ask to select the .sqlite database file, but it would be nice if this would happen automatically. Do I need to set a path to the database file and if so, how do I do this? I have the OpenDatabase method called for in the main App.
Where are-you storing the data base file ?
In the same folder as the main Xojo files.
The LR is your best friend:
Var db As New SQLiteDatabase
db.DatabaseFile = New FolderItem("db.sqlite")
// db.EncryptionKey = "howdy+doody"
Try
db.Connect
Catch error As IOException
// handle error here
MessageBox(error.Message)
End Try
from:
http://documentation.xojo.com/api/databases/sqlitedatabase.html
What’s LR?
LR = Language Reference
ah… thanks.
Yes, I have the same kind of script, and it opens the database correctly, However, I have to browse to the folder where the database is saved manually and I would like to have it open automatically whenever I run the project.
Once the user selects the path the first time, save it to a text file in the users app data folder. On startup check for the text file, it is there, read the path and open the database. If the file is not there, or the path is not valid, open the file dialog to find it.
This way the user only has to select the database path once.
This is a huge NO-NO… please store you database in the proper place ApplicationSupport folder