forum

Home / DeveloperSection / Forums / Sqlite Database Backup

Sqlite Database Backup

Ajay Kembale 2616 12-Jan-2016
I want to take backup of sqlite database in windows application(Visual Studio 2012).I am able to do it using Sqlite in mozila firefox addon manually.
But I want to implement it on a button click in windows form.I was trying following  code which errormessage 'BackupDatabase() does not exists in System.Data.SQLite.SQLiteConnection

I was looking for query in Sqlite but I couldnt find anything

public void takebackup()
        {
            da = new SQLiteDataAdapter();
            //con.Open();
            try
            {
                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, "main", "main", -1, null, -1);
                cnnIn.Close();
                cnnOut.Close();
            }
            catch (Exception er)
            {
            }
            finally
            {
                //con.Close();
            }
        }

Updated on 27-May-2023

Can you answer this question?


Answer

2 Answers

Liked By