Here is a quick example that copies a small database from memory to disk:
using System.Data.SQLite;
namespace BackupAPI
{
class Program
{
public static void BackupAndGetData()
{
using (SQLiteConnection source = new SQLiteConnection(
"Data Source=:memory:"))
{
source.Open();
using (SQLiteCommand command = new SQLiteCommand())
{
command.CommandText =
"CREATE TABLE t1(x TEXT); " +
"INSERT INTO t1 (x) VALUES('123456789');";
command.Connection = source;
command.ExecuteNonQuery();
}
using (SQLiteConnection destination = new SQLiteConnection(
"Data Source=test.db"))
{
destination.Open();
source.BackupDatabase(destination, "main", "main",
-1, null, 0);
}
}
}
static void Main(string[] args)
{
BackupAndGetData();
}
}
}
--
Joe Mistachkin
Okay, that's easy. I didn't realize that it's a method of the Connection
object. Thanks for providing the snippet.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users