Reputation: 3548
I am upgrading System.Data.SQLite from version 1.0.93.0 to 1.0.111.0
I am having a method which copies the SQLite database on disk to in memory. It is working fine with version 1.0.93.0 and here's the code in VB.Net
Dim sourceConn = CType(_connection, System.Data.SQLite.SQLiteConnection)
Dim destConn = CType(destDBM._connection, System.Data.SQLite.SQLiteConnection)
sourceConn.BackupDatabase(destConn, "main", "main", -1, Nothing, 0)
where path of destination SQLite is in memory by using ":memory:" instead of path.
After upgrading to version 1.0.111.0, it throws the below exception
code = Unknown (-1), message = System.Data.SQLite.SQLiteException (0x80004005): unknown error failed to initialize backup at System.Data.SQLite.SQLite3.InitializeBackup(SQLiteConnection destCnn, String destName, String sourceName) at System.Data.SQLite.SQLiteConnection.BackupDatabase(SQLiteConnection destination, String destinationName, String sourceName, Int32 pages, SQLiteBackupCallback callback, Int32 retryMilliseconds)
Does anyone have any idea that how to get it solved?
Upvotes: 2
Views: 760
Reputation: 3548
I am able to find out the root cause of this issue myself. Actually, I was starting a transaction in destination database before backup. It was working fine in the older version but the behavior is changed in the latest version and exception is not meaningful at all.
To fix it, I have re-ordered the code which was initiating transaction as the next step after taking backup. It's working as expected now and insertions are way too fast in the latest version. Great work by SQLite team!
Upvotes: 2