1SQLiteConnection source = new SQLiteConnection("Data Source=c:\\test.db"); 2source.Open(); 3 4using (SQLiteConnection destination = new SQLiteConnection("Data Source=:memory:")) 5{ 6 destination.Open(); 7 8 // copy db file to memory 9 source.BackupDatabase(destination, "main", "main",-1, null, 0); 10 source.Close(); 11 12 // insert, select ,... 13 using (SQLiteCommand command = new SQLiteCommand()) 14 { 15 command.CommandText = "INSERT INTO t1 (x) VALUES('some new value');"; 16 17 command.Connection = destination; 18 command.ExecuteNonQuery(); 19 } 20 21 source = new SQLiteConnection("Data Source=c:\\test.db"); 22 source.Open(); 23 24 // save memory db to file 25 destination.BackupDatabase(source, "main", "main",-1, null, 0); 26 source.Close(); 27}
SQLite 文件使用 Memory 模式
Easter79
2021-10-12
1206 0 0
点赞
收藏
评论区
加载中...