New SQLiteDatabase file problem

Once again I think I might be getting senile.

I need to create a new SQLiteDatabase file - not recreate, but create a new one in an empty folder.

J have a folder on my desktop (OS X 10.10.5 Yosemite, Xojo 2017r1.1) called TestNewDatabase - empty.

I have the following code in the Action event of a button. It goes through the code and says the database was successfully created.

EXCEPT - when I look in the folder there is nothing there…
EXCEPT - if I do a search on the database name it says it’s there in the TestNewDatabase folder.

So, it seems like it there but it’s not there…

Please help.

Dim dlgGetDatabasePath   As New SelectFolderDialog
Dim fDBPath           As FolderItem
Dim fDBFile              As FolderItem
Dim sNewPath        As String
Dim sNewFile          As String
dim dbSQL              As SQLiteDatabase

dlgGetDatabasePath.ActionButtonCaption = "Select"
dlgGetDatabasePath.Title = "Select Path for new Database File"
dlgGetDatabasePath.InitialDirectory = SpecialFolder.Desktop

fDBPath = dlgGetDatabasePath.ShowModal
If fDBPath <> Nil Then
  sNewPath = fDBPath.NativePath
  sNewPath = "Not Selected"
End If

sNewFile = sNewPath + "/dbfilename.sqlite"
fDBFile = new FolderItem(sNewFile)

dbSQL = New SQLiteDatabase
dbSQL.DatabaseFile = fDBFile
If dbSQL.CreateDatabaseFile then
  MsgBox("Database File Created Successfully!")
  MsgBox("Database Error: " + dbSQL.ErrorMessage)
End If


Don’t do it this way. If there is a problem with the path (like a character that needs to be escaped), you’ll get Nil back from New FolderItem, which will successfully create a database, but it will be in-memory. Instead, use Child().

fDBFile = fDBPath.Child("dbfilename.sqlite")

Made the change and it work correctly.

thanks Tim.