Following SQLite Example from Xojo I tried the following change in CreateDBButton:
Var dbFile As FolderItem = SpecialFolder.Documents.Child(“Temporary”) in place of the original
Var dbFile As FolderItem = SpecialFolder.Desktop.Child(“example.sqlite”)
The original one works fine, its replacement gives me the following error whne clicking the button:
**An exception of class IOException was not handled. The application must shut down.
Exception Message: The directory is not empty
Exception Error Number: 39**
There is no DB of any kind in the Temporary folder, I don’t ubderstand what’s wrong and how can I creat a DB wherever I like.
Can anybody help?
Does the Temporary file exist in your Documents folder?
Yes it does.
It’s not empty, as it contains different items but no DB
It is failing because you have changed the behavior and didn’t account for the changes. By changing it to point to a folder, the later Delete code cannot work because the folder is not empty. Perhaps you want to point to a DB file within the folder?
You would need the following line as you’re trying to make a database called “Temporary” where a directory is already in its place.
Var dbFile As FolderItem = SpecialFolder.Desktop.Child("Temporary").Child("example.sqlite")
Thanks, I don’t have the I/O error anymore but I get: “Unable to open database file”. It looks like it does not create the DB at all
Odd, it did here. What OS and version of Xojo are you using?
Catalina 10.15.6 and Xojo 2019 R3.2
Maybe a mac user can help you there, it could be a security issue writing to the desktop.
if there is no sqllite file in the Temporary folder, and you want one there, you either need to put one there before you start,
use CreateDatabaseFile to create one.
if you dont do the create, there is no file to open.
The docs have this:
Var dbFile As FolderItem
dbFile = SpecialFolder.ApplicationData.Child(“MyDatabase.sqlite”)
// DB As SQLiteDatabase is a property on the App object
App.DB = New SQLiteDatabase
App.DB.DatabaseFile = dbFile
If App.DB.CreateDatabaseFile Then
// Use the database
For your purposes:
Var dbFile As FolderItem = SpecialFolder.Desktop.Child(“Temporary”).child(“mydatabase.sqllite”)
var thedb as New SQLiteDatabase
thedb.databasefile = dbFile
if dbfile <> nil and dbfile.exists then
//open and use the db
If thedb.CreateDatabaseFile Then
// Use the database
Ok. It seems to work now. I missed the CreateDatabaseFile part, I probably cancelled it by mistake.