fedeteka fedeteka - 1 year ago 282
Vb.net Question

Backup SQLite database with VB.Net

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.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")

Using (conn)


conn.BackupDatabase(connbackup, "main", "main", -1, null, 0)

End Using

Catch ex As Exception
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

enter image description here

Answer Source

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.BackupDatabase(destination, "main", "main", -1, Nothing, 0)
End Using
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download