Store db file in shared directories

424 views Asked by At

when i am install my application to client machine which have window 7 then give me error that db file don't have read or write permission.

how can i give permission to that file ?

i already read other solution that i should store the db file in shared directories which have read write permission for every user.

but i want to store my database file into my program files folder and want to give permission to that file so it can also work in window 7 .

thanks

EDITED :--

as now all of you suggesting to save the db files in shared folder so my new question is now

how to store .mdf file in shared folder when making setup in c#. what changes should i make in app config file. currently its storing program files in my application folder where my application don't have read write permission .

currently my mdf file is on root and my app config file have this line of code :

<add name="HotelReservationSystem.Properties.Settings.HotelReservationDBConnectionString"
      connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HotelReservationDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
      providerName="System.Data.SqlClient" />
1

There are 1 answers

8
MyKuLLSKI On BEST ANSWER

Unfortunately after Windows XP this is NOT possible. In order for a user to write to anything in Program Files they need Administrator access. Not only do they need Administrator access but they also need UAC permission.

So you have to options

  1. Place the database in a read/write folder like ApplicationData
  2. Make your app run as admin UAC rights by adding the setting in app.manifest