Can't Connect to a Database

I am trying to connect to a SQLite Database which is in the same directory as the .xojo_project. This project was formerly a Real Studio project which worked fine.

The lines I am using are:

Dim AROFile as FolderItem
AROFile = GetFolderItem(“AROData.rsd”)

If AROFile.exists Then
MsgBox(“It exists”)
else
MsgBox(“It Doesn’t Exist”)
End If

The last part tells me “It Doesn’t Exist”

It then goes on to tell me, quite correctly, that it can’t connect to the database

Any ideas?

John.

The GetFolderItem is relative to the location of the executable, so if you’re running a built app within your builds folder, that might be looking somewhere else than where it would look if you’re simply debugging the app.

It might help to reference the file’s absolute location, such as moving the file to your desktop and using SpecialFolder.Desktop.Child(“AROData.rsd”), or storing it within an appropriate application support folder.

As Tom indicates, you need to specify the path to the database relative to the executable application. Change

AROFile = GetFolderItem("AROData.rsd") 

to something like (off the top of my head)

AROFile = GetFolderItem("").Parent.Child("AROData.rsd")

for while you are debugging/developing the app. For the release version, it is better to put the database file in the SpecialFolder hierarchy somewhere (SpecialFolder.ApplicationData).

John,

.rsd is fine while .sqlite can be better (according to the Xojo documentation).

Watch carefully that page:
http://documentation.xojo.com/index.php/SQLiteDatabase

Oh: this is not related to your problem.