繁体   English   中英

在Windows Phone 8中,SQLite可以工作,但不会将数据库文件写入IsoStore

[英]In Windows Phone 8, SQLite works but doesn't write the database file to IsoStore

我的应用程序使用sqlite-net-wp8 for Windows Phone 8来管理本地数据库。

似乎数据库文件永远不会写入IsoStore(与IsoStoreSpy )。 没有异常被抛出。

我尝试过以下方法:

  • 将SQLite for Windows Phone从3.7.1.16升级到3.8.0.2(这是一个非常痛苦的过程)

  • 提供绝对和相对路径,如在Windows Phone 8中使用sqlite建议的移动版sqlite网络版

     SQLite.SqliteConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, filename)) SQLite.SqliteConnection(filename) 
  • 将SQLiteOpenFlags显式提供给SQLite.SQLiteConnection

  • 其他随机的东西

这是我的代码(我正在使用USE_WP8_NATIVE_SQLITE

string filename = "data.db";
string seqStr = "CREATE TABLE ...";
using (SQLiteConnection db = new SQLite.SQLiteConnection(filename, 
    SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite, true))
{
    db.BeginTransaction();
    db.Execute(seqStr);
    db.Commit();
    db.Close();
}

我已经没想完了。 如果有人可以帮助我,我会非常感激。

终于,解决了!

你是对的, db.Close()是多余的(Dispose将调用Close()函数。

我的非工作代码:

string filename = "Data Source=" + "data.db" + ";Version=3;New=False;Compress=True;"

我现在的工作代码:

string filename = Path.Combine(ApplicationData.Current.LocalFolder.Path, "data.db");

一个小路障被移除,还有更多去!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM