SQLite Forum

unable to open database file
Login

unable to open database file

(1.1) Originally by Shakoor (afa9406) with edits by Richard Hipp (drh) on 2020-08-27 10:57:22 from 1.0 [link] [source]

Hi: I am shakoor, I develop a vb.net desktop application using SQLite database file, on updation of any table, it generate error "unable to open database file", The file path is Program File\My Program\My Product Name, As I change the file path from Program File to another directory or Drive its behavior is normal and updation done, again placing in Program File, it generating error, I have already given the full control to user. Please help me to resolve this issue. thanks

(2) By anonymous on 2020-08-27 11:03:37 in reply to 1.1 [source]

The file path is Program File\My Program\My Product Name As I change the file path from Program File to another directory or Drive its behavior is normal

It looks like you are being bitten by file system redirection. If your program is built for 32-bit Windows, trying to access Program Files on 64-bit Windows will redirect it to Program Files (x86) instead.

(3) By Ryan Smith (cuz) on 2020-08-27 15:05:06 in reply to 1.1 [link] [source]

Further to what Anonymous said, both "Program files" and "Program files (x86)" are what is considered protected locations in Windows so that other programs cannot modify your programs' stuff.

To enforce this, nobody is allowed to write there without super-user access (trying to be all grown-up like Linux, but without the explicitness) and so it will virtualize the folder, that is: Make/Access the actual file somewhere else that is user-specific. This is only if you have UAC turned ON (which by default it is), so even if you "fix" your dev system by turning it off, users of your app will still have this problem.

You might think now that you only need to read the DB, you don't write it, so why does it care about reading? Well, SQLite still needs to write the files alongside the DB to open it with Transactional capability.

The correct route is to find out the proper folders to use for your data. Luckily, there are standard windows APIs and for which almost all programming platforms have some standard functions to find - but that is not for this forum.

I will say that typically in Windows, the good path for application data turns out to be something like: c:Users{the_actual_user_name}appdataroaming{your_app_name}...

It differs obviously from user to user, and also between whether you want data available to all-users or to just the installing user, or if the use is intended on the local machine only or on a roaming profile, etc. etc. - that's why the simplest is to just use the built-in functions and get the good folders for app data.

Your programming platform's fora will have countless examples and directions. Here's how to get it for VB.NET: https://lmgtfy.com/?q=Find+Windows+application+data+folder+in+VB.NET

Good luck!