in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

Attempt to write to read-only database

Last post 10-28-2011 8:55 AM by thready. 20 replies.
Page 2 of 2 (21 items) < Previous 1 2
Sort Posts: Previous Next
  • 07-05-2010 11:11 AM In reply to

    • BobVal
    • Top 200 Contributor
    • Joined on 12-04-2009
    • Posts 8

    Re: Attempt to write to read-only database

    After an initial install (using InstallShield LE and Visual Studio 2010) my C++ program is unable to write to a database that I know is open properly.

    This is what I have found out.  If I right click on my program and RUN AS ADMINISTRATOR everything is FIND FOREVER even when I run it normal after this.

    So this has something to do with Windows 7 rights and UNKNOW publisher.

    Is there an easy way around this?

     

    Bob

  • 07-05-2010 3:51 PM In reply to

    • rkulp
    • Top 10 Contributor
    • Joined on 06-28-2008
    • Rural Coffee County, Tennessee
    • Posts 73

    Re: Attempt to write to read-only database

    I had a similar problem. Everything worked fine in the IDE but not when installed. It turned out to be a permissions problem for the folder (I put it in a sub directory of ProgramData). The solution was to grant read, write, execute and list contents priviledges to the folder in the installation package. This was easy in Advanced Installer. I don't know how it would be in your program. 

  • 10-17-2011 11:05 AM In reply to

    Re: Attempt to write to read-only database

    Hi seinkraft!  I have this same problem.  I tried what you are suggesting and it doesn't help - have you seen any other ways to fix this problem since?  (you were saying to run the app using SQLite as admin to alleviate the "attempt to write to readonly database".

    I did set my app as run as admin and the problem occurs after the 6th "CREATE TABLE IF NOT EXISTS".  The previous 5 already existed.  I'm adding to my database and now I'm wondering if SQLite doesn't like it if you modify the table structure to an existing database...

    Thanks!

    Mike

    Filed under:
  • 10-17-2011 11:08 AM In reply to

    Re: Attempt to write to read-only database

    I tend to agree with this Bob- did you figure this out?  Unfortunately for me, setting to run as admin doesn't help....
  • 10-28-2011 8:39 AM In reply to

    Re: Attempt to write to read-only database

     It's sounds like you're just getting aquainted with Windows 7 security defaults.  Generally speaking (and I do mean "generally"), MS now wants you to put your data bases/files in directories like "Documents"  or "AppData" going forward AND to "help" us with this, they've changed the directory defaluts among other things.  If you can, relocate your DB's.  And naturally, there's a down side.  AppData, which can be referenced directly via C: etc. has some odd characteristics...like it's invisible and you have to set bits to see it.  Documents is pretty good but it can be relative to the domain environment.  We ship computers/evironments with our product so have the luxury of being able to force our customers into particular directory structures.

     If you really want to install your app including db in the Program files or PF x86 directory, you'll have to change the directory security to read/write as the default is now (with Win 7) read only.  This is a lot trickier than it sounds and quite frankly we only did this manually a couple times and after agonizing our way through it, we decided that we'd do what MS wanted us to.  (To give you a heads up, you'll change directory security in Windw Explorer and it will lie to you and tell you that you've changed it. BUT if you run your app or return to Windows Explorer, you'll see it didn't chage the setting.  Next time my users piss me off, I'm writing something like this myself.)   Sqlite is apparently (from our experience and deduction, not looking at the source code), seems to be subject to the directory settings in which it is located...which of course makes complete sense. You can google how to change the security for the directory but it's tricky.  AND our experience is that if you add a new user to your machine, the directory security gets reset.

  • 10-28-2011 8:55 AM In reply to

    Re: Attempt to write to read-only database

    Thanks jbmckim!
Page 2 of 2 (21 items) < Previous 1 2
Powered by Community Server (Commercial Edition), by Telligent Systems