Unable to attach sqlitedatabase

Hi,

My project (built using xojo version 2019 release 3.1) uses an sqlite database that is created in the SpecialFolder.ApplicationData folder on startup. In the App.Open event handler, first it connects to the sqlite database called MainDatabase, which is encrypted. Then it attaches a second sqlite database, UserData.db, also in the AppData folder, which is not encrypted.

Var myDBFile As FolderItem = SpecialFolder.ApplicationData.Child(ActiveApp.Name).Child("UserData.db") If myDBFile <> Nil And myDBFile.Exists Then Var sql As String = "ATTACH DATABASE '"+myDBFile.NativePath+"' AS ud KEY ''" If Not MainDatabase.SQLExecute(sql) Then MessageBox("Error. Unable to attach User Data.") Quit End If Else MessageBox("UserData.db missing from Application Data folder" + EndOfLine + CurrentMethodName) End If

Out of several hundred users of my app, one person has reported an issue where they are getting the “Error. Unable to attach User Data.” messagebox, on their Windows laptop. I’m not sure what OS they are using. They have experienced the error using both 32 bit and 64 bit versions of my app.

I have verified that the MainDatabase and UserDatabase files have actually been created and exist in the AppData folder. Would anyone have any ideas as to why the attachment might fail, or how to try to troubleshoot this issue?

Thanks for your help,
Frank

Add more precise error detecting into your software, so you will have real clues to where to search.

But, maybe your user trashed the file / the used Windods trashed the file / a rename of the db file have been done (by error) / the data base have been moved / you do not place your data in a folder in that ApplicationFolder / the data base file was deleted for unknow reason, but not created back by your software at run time…

There can be so many reasons (a boot from a different hard disk ?)

Hi Emile,

Thanks for your suggestions. Both the MainDatabase file and the UserData.db file are created in the AppData folder on startup of the app, if they do not already exist. So they should be there, even if they were previously deleted somehow. But you are right, I need to get the DatabaseException message. My code is currently set up to System.DebugLog the error message if it’s a DebugBuild but not for the end user. I’ll change that and hopefully the user can send me the report.

Cheers,
Frank