System.Data.SQLite BackupDatabase() throws “not an error”

冷暖自知 提交于 2019-12-22 18:34:58

问题


I'm using System.Data.SQLite (version 1.0.85.0) to connect with my SQLite database. I want to create backup of the database using SQLiteConnection.BackupDatabase() method, however it throws SQLiteException with message:"not an error" (repeated twice). Here is some code:

SQLiteConnection cnnIn = new SQLiteConnection("Data Source=test.db;foreign keys=True");
SQLiteConnection cnnOut = new SQLiteConnection("Data Source=backup.db;foreign keys=True");
cnnIn.Open();
cnnOut.Open();
cnnIn.BackupDatabase(cnnOut, "backup", "test", -1, null, -1);
cnnIn.Close();
cnnOut.Close();

The error comes from System.Data.SQLite.SQLite3.InitializeBackup(SQLiteConnection destCnn, String destName, String sourceName)

Does anyone knows what could be wrong?

PS. I must say error message is a bit misleading :)


回答1:


I use the same method to perform methods, but as the database name, I use main:

cnnIn.BackupDatabase(cnnOut, "main", "main", -1, null, -1);

Does it work with this change?



来源:https://stackoverflow.com/questions/17298988/system-data-sqlite-backupdatabase-throws-not-an-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!