System.Data.SQLite slow connect for non-admin users
Asked Answered
V

2

6

I have a .NET 4 application (in mixed mode) with System.Data.Sqlite (1.0.82) for database access to an encrypted database.

When I install the application to "c:\program files\myfolder" the connect to the sqlite database file is slow. Log files show that it's the sqlite connect statement that is delayed by a few seconds.

The problem does not occur when I do the following:

  • Run the application with admin privileges
  • Install any other place than c:\program files\
  • Install the application to c:\program files\, but move the database to another folder.

I have no clue what can be the cause of this...

Valerianaceous answered 16/10, 2012 at 6:47 Comment(0)
A
5

If the DB file is in the application directory then it's most likely that the UAC is moving it to the "...appdata\Local\VirtualStore\Program Files" directory. Best practice is to create your own appdata\MyApp folder and copy the pristine DB out of the c:\program files\MyApp folder.

Abie answered 23/11, 2012 at 6:13 Comment(0)
G
1

It helps to open the database in read-only mode. (You should keep only read-only stuff in the program files folder anyway.)

Just append ";Read Only=True" to the connection string.

private const string CONN_TEMPL = "Data Source={0};Version=3;Read Only=True";
var conn = new SQLiteConnection(
    String.Format(CultureInfo.InvariantCulture, CONN_TEMPL, databasePath)
);
Gnomon answered 25/11, 2014 at 16:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.