2016-01-13 74 views
0

Memory Stream as DB如何使用C#或SQLite的查詢

我已經使用這個鏈接,介紹了代碼,以SQLite數據庫備份我ERRORMESSAGE是

BackupDatabase()不 System.Data.Sqlite存在.SqliteConnection

是否有任何Sqlite查詢來備份或導出Sqlite數據庫。 然後再次恢復它

我想導出數據庫在一個系統上,然後導入到另一個系統中安裝在兩個系統上的相同的Windows應用程序。 我想按鈕點擊實現這個活動。

+0

是否使用的是System.Data.SQLite的版本? –

+0

版本: - SQLite 3.8.11.1。我已經通過Addons將它添加到mozila firefox中。我認爲它僅提供以下功能表,視圖,索引和觸發器。我在SQL Server中考慮的工作更容易,但在Sqlite數據庫中更容易。 – Ajay

+0

3.8.11.1是SQLite庫本身的版本。什麼是C#System.Data.SQLite包的版本? –

回答

0

System.Data.SQLite 1.0.74.0相當過時。 對於備份API支持,至少需要版本1.0.80.0,但您可以升級到最新版本。

+0

好吧,我會嘗試它會很快回來,在提前感謝! – Ajay

+0

我將System.Data.Sqlite從版本1.0.74.0升級到1.0.99.0,現在BackupDatabase()方法正在運行非常多。 – Ajay

0

試試這個

using (var destination = new System.Data.SQLite.SQLiteConnection(string.Format("Data Source={0}\\DriversTrucksBackup.db; Version=3;", this.txtLocation.Text))) 
        { 
         da.cn.Open(); 
         destination.Open(); 
         da.cn.BackupDatabase(destination, "main", "main", -1, null, 0); 
         da.cn.Close(); 
        } 
0

備份數據庫link SQLite中link試試這個功能

public void backup(string strDestination) 
{ 
     using (var location = new SQLiteConnection(@"Data Source=C:\activeDb.db; Version=3;")) 
     using (var destination = new SQLiteConnection(string.Format(@"Data Source={0}:\backupDb.db; Version=3;", strDestination))) 
     { 
      location.Open(); 
      destination.Open(); 
      location.BackupDatabase(destination, "main", "main", -1, null, 0); 
     } 
}