Can't Open SQLite Database

Hi everyone,

I am very new to Xojo and it seems like a tool that could be very helpful with my current project - IF ONLY I COULD OPEN A DATABASE FILE!!! I am sure I am missing something really stupid and I would greatly appreciate any advice (I have been pulling my hair out over this for 6 hours).

Here is the code I am using:

Dim dbFile As FolderItem
Dim db As New SQLiteDatabase
If dbFile.exists Then
MsgBox(“It exists”)
End If

db.DatabaseFile = dbFile
If db.Connect Then
MsgBox("The database couldn’t be opened. Error: " + db.ErrorMessage )
End If

The message box confirms that the file exists but then when I try to connect I get an error say 'Unable to Open Database File" I have declared a property for ‘db’, I know the file is there and I have confirmed it’s integrity by opening it with SQLIte Database Browser - what am I missing???

GetFolderItem("").Parent is more than likely a directory - not a db file
You can confirm this with
If dbFile.exists Then
MsgBox(dbFile.AbsolutePath + " exists")
End If

I’d guess if the db file is next to your app you’d need to do something like

dbFile=GetFolderItem(“database”).Parent.Child( name_of_db_file_here )