lundi 2 février 2015

Overwrite fails after closing database with Sqlite.Interop.dll (version 1.0.94) C# . NET CF2.0

My application requires three SQLite databases. Let's call them "Name1", "Name2" and "Name3". Their sizes are 22.6 Mb, 45 Kb and 298 Mb respectively. I have a task that every night downloads a zip containing new versions of the databases and copies them over the existing versions.


Before overwriting, I check if the database files are open and close them if necessary. I am using SQLite.Interop.dll (version 1.0.66) together System.Data.SQLite. I open the databases like this:



mysqliteConnection1 = new SQLiteConnection("Data Source=" + Name1 + ";Journal Mode=Off;Cache Size=999999;Synchronous=Off;PRAGMA locking_mode=EXCLUSIVE;PRAGMA read_uncommitted=False;");
mysqliteConnection2 = new SQLiteConnection("Data Source=" + Name2 + ";Journal Mode=Off;Cache Size=999999;Read Only=True;Synchronous=Off;PRAGMA locking_mode=EXCLUSIVE;PRAGMA read_uncommitted=False;");
mysqliteConnection3 = new SQLiteConnection("Data Source=" + Name3 + ";Journal Mode=Off;Synchronous=Off;PRAGMA locking_mode=EXCLUSIVE;PRAGMA read_uncommitted=False;");


If a database file is open, I close the connection like this:



mysqliteConnection1.Close();


Next I unzip my zip file with Ionic (DotNetZip). Ionic successfully overwrites all three databases. All works fine.


When I try with the latest SQLite.Interop.dll (version 1.0.94), I have a problem unzipping the zip file. In the case of the third database, "Name3", When Ionic wants to overwrite the original file by the unzipped file, it throws an exception saying that the file is already in use by another process.


Has someone else had the same problem with the new SQLite ?


Aucun commentaire:

Enregistrer un commentaire