2

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
  • 6
    throws “not an error” - awesome. Commented Jun 25, 2013 at 13:44

1 Answer 1

14

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?

Sign up to request clarification or add additional context in comments.

2 Comments

Can you explain what is the reason to use "main" instead of database name?
"InitializeBackup" calls "sqlite3_backup_init," the valid db names are "main", "temp", or the AS alias of an attached database. (see: sqlite.org/c3ref/backup_finish.html#sqlite3backupinit)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.