First I wanto to say that I am an inexperienced xojo programmer.
I’m testing xojo with sqlite on desktop platform on mac os.
I’d like to open asqlite database and leaves opened for further operations so as far I can understant I’ve created a property as sqlitedtabase and visibility public and a method to open the database.
the method open database is below
Dim dbFile As FolderItem
dbFile = SpecialFolder.ApplicationData.Child(“gestio.sqlite”)
Dim db As New SQLiteDatabase
db.DatabaseFile = dbFile
If db.Error Then
MsgBox("Error: " + db.ErrorMessage)
End If
BaseDades = db
The last line is the property BaseDades that I want to use in methods.
Unfortunately, when I want to use this property in otger methods I get and error “Datbase is not open”
For better experience change the database location to desktop dbFile = SpecialFolder.desktop.Child("gestio.sqlite") or in the Documents folder dbFile = SpecialFolder.documents.Child("gestio.sqlite") and move the file there.
and change the bellow part
If db.Error Then
MsgBox("Error: " + db.ErrorMessage)
End If
to
If DB.Connect Then
MsgBox("Connected to " + dbFile.Name)
Else
MsgBox("Error: " + db.ErrorMessage)
End If And check if the property is Global…