if the folder item is nil thats what I would expect since
dim db as new SQLiteDatabase
break
if not db.Connect then
MsgBox("not connected to db")
else
MsgBox("connected to db")
end if
is how you connect to an in memory db and the database file is nil at the break
Not sure how it could distinguish
About the only way to test is to have a valid folder item and check “exists”
No
The first one has a VALID non-nil folderitem that simply doesn’t exist
The correct course of action would be NOT to connect but to CREATE the database file
The second has a NIL folderitem so it connects to one in memory
Yes, I was thinking that the first was nil when it just didn’t exist. I guess I was hoping for functionality along the lines “you tried to assign a non-existent folderitem to a databasefile so I’m not going to connect.” When in doubt, error check.
db = New SQLiteDatabase
Dim dbf As FolderItem = SpecialFolder.UserHome.Child("myDB.sqlite") // Not the best place
db.DatabaseFile = dbf
if dbf.Exists Then // Exists, open
If Not db.Connect Then
MsgBox "Oops. Open error: "+db.ErrorMessage
Quit
End
Else
If db.CreateDatabaseFile Then // New. Create it
db.SQLExecute(SQLCreateDB) // Create tables and structures
If db.Error Then
MsgBox "Create db struct error: "+db.ErrorMessage
Quit
End
Else
MsgBox "Create db error: "+db.ErrorMessage
Quit
End
End