使用 VB.Net 备份 SQLite 数据库 [英] Backup SQLite database with VB.Net
本文介绍了使用 VB.Net 备份 SQLite 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我没有找到 VB.NET 的文档
尝试调整
解决方案
这是 C# 代码的直接翻译:
Using source As New SQLiteConnection("Data Source=ActiveDb.db; Version=3;"),destination As New SQLiteConnection("Data Source=BackupDb.db; Version=3;")源.Open()目的地.Open()source.BackupDatabase(destination, "main", "main", -1, Nothing, 0)结束使用
I don't find documentation for VB.NET
Trying to adapt the code of the answer on Sqlite Online Backup Using System.Data.Sqlite
The code from @Elias is:
using(var source = new SQLiteConnection("Data Source=ActiveDb.db; Version=3;"))
using(var destination = new SQLiteConnection("Data Source=BackupDb.db; Version=3;"))
{
source.Open();
destination.Open();
source.BackupDatabase(destination, "main", "main", -1, null, 0);
}
and my code looks like:
Dim conn = New SQLiteConnection("Data Source=MyBase.sqlite;Version=3;Password=myPassword;foreign keys=true")
Dim connbackup = New SQLiteConnection("Data Source=MyBaseBackup.sqlite; Version=3;Password=myPassword;foreign keys=true")
Try
Using (conn)
conn.Open()
connbackup.Open()
conn.BackupDatabase(connbackup, "main", "main", -1, null, 0)
End Using
Catch ex As Exception
MsgBox(ex.ToString())
End Try
Visual Studio marks on red "Null" is not declared and I don´t have any clue about how to solve the error. I think is the "callback" what is wrong
解决方案
Here is the direct translation of that C# code:
Using source As New SQLiteConnection("Data Source=ActiveDb.db; Version=3;"),
destination As New SQLiteConnection("Data Source=BackupDb.db; Version=3;")
source.Open()
destination.Open()
source.BackupDatabase(destination, "main", "main", -1, Nothing, 0)
End Using
这篇关于使用 VB.Net 备份 SQLite 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文