views:

150

answers:

3

i have my c# application in c:\program files\app\ folder i am using sqllite database

my code working perfectly while logging via windows administrative user, if i change window user account to limited, i couldn't open my database

public  void OpenDB()
{
 SQConnectionString = "Data Source=" + DBPath +";Pooling=true;FailIfMissing=false";
 con = new SQLiteConnection();
 con.ConnectionString = SQConnectionString;
 con.Open();
}
A: 

Does the non-admin user have write privileges on the directory where you installed SQLite? Because this might happen if you are using the journal file.

APC
A: 

That's because non-admin users don't have write access to the program files folder

wefwfwefwe
+2  A: 

The Program Files directory is definitely not the right place to put data... On Windows Vista and Seven, this directory can't be written to unless the application is running as administrator. You should put the database in ProgramData or the user's data directory. You can obtain these directories with the Environment.GetFolderPath method :

string userAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
// On Vista and Seven, this is C:\Users\<username>\AppData\Roaming
// On XP, this is C:\Documents and Settings\<username>\Application Data

string commonAppData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
// On Vista and Seven, this is C:\ProgramData
// On XP, this is C:\Documents and Settings\All Users\Application Data
Thomas Levesque
thanks for your fast response
JKS