Not connecting to sqlite database after buying license and downloading last version

Project was working fine last november and after buying the license and downloading the last version of xojo and now cant connect to the database. What has change in the last version.
Here is the code in the app event handler open properties

var temp as string = App.ExecutableFile.NativePath
var i as integer = len(temp)
temp = temp.middle(0,i-23)
db = new SQLiteDatabase
db.DatabaseFile = new FolderItem(temp+“camionnage.sqlite”)
Catch e as DatabaseException
end try

after relaunching the xojo application, the project works again but when i build it i have this error


Instead of that string manipulation for the path just use:

That said, if you’re building for macOS, next to the new executable really isn’t the right place for a database.

Greg is right, you should use the folderitem directly as he showed and you should reconsider the right place to keep the SQLite database-file.
But, according to my knowledge this shouldn’t cause the message you got in a messagebox as long as you’re working in debugmode. @Benoit_Porlier is it possible that you tested a compiled version while you did not catch errors in your code?

I suspect that code to grab the 23 characters relies on .debug being in the name (or not).

Thank you very much for the help, its very appreciated :smile:
So i changed the code to this

db = new SQLiteDatabase
db.DatabaseFile = FolderItem(app.executablefile.parent.child(“camionnage.sqlite”))
Catch e as DatabaseException
end try

but now i recieve the same error code in the ide instead of when running the compiled application.
Once i figure out the database connection i will move it in a sub folder and also im running on windows and the app is intended for windows too
im new to building application but i love to learn. Thank you very much again for the help.

I’m sure you need:

db.DatabaseFile = FolderItem (app.executablefile.parent.child(“camionnage.sqlite”), FolderItem.PathModes.Native)

What do you mean “in the IDE”? And what error code?

To simplify this, you don’t need the cast:

db.DatabaseFile = app.executablefile.parent.child(“camionnage.sqlite”)

This all assumes that the database file is in that relative position. When you run, the app is put in the folder next to the project, but building causes it to be placed in its own folder. You should add a CopyFiles build step to make sure the database gets copied next to the app.