[英]In Windows Phone 8, SQLite works but doesn't write the database file to IsoStore
My app is using sqlite-net-wp8
for Windows Phone 8 to manage a local database. 我的应用程序使用sqlite-net-wp8
for Windows Phone 8来管理本地数据库。
It seems that the database file is never written to IsoStore (as seen with IsoStoreSpy
). 似乎数据库文件永远不会写入IsoStore(与IsoStoreSpy
)。 No exceptions are thrown. 没有异常被抛出。
I have tried the following: 我尝试过以下方法:
Upgrading SQLite for Windows Phone from 3.7.1.16 to 3.8.0.2 (an extremely painful process) 将SQLite for Windows Phone从3.7.1.16升级到3.8.0.2(这是一个非常痛苦的过程)
Providing absolute and relative paths as suggested in Working with sqlite in windows phone 8 a sqlite net version for mobile . 提供绝对和相对路径,如在Windows Phone 8中使用sqlite建议的移动版sqlite网络版 。
SQLite.SqliteConnection(Path.Combine(ApplicationData.Current.LocalFolder.Path, filename)) SQLite.SqliteConnection(filename)
Providing SQLiteOpenFlags explicitly to the SQLite.SQLiteConnection 将SQLiteOpenFlags显式提供给SQLite.SQLiteConnection
Other random things 其他随机的东西
Here is my code (I am using USE_WP8_NATIVE_SQLITE
) 这是我的代码(我正在使用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();
}
I have run out of ideas. 我已经没想完了。 If someone can help me, I would be really grateful. 如果有人可以帮助我,我会非常感激。
Finally, solved! 终于,解决了!
You are right, db.Close()
is redundant (the Dispose will call the Close() function. 你是对的, db.Close()
是多余的(Dispose将调用Close()函数。
My non-working code: 我的非工作代码:
string filename = "Data Source=" + "data.db" + ";Version=3;New=False;Compress=True;"
My now working code: 我现在的工作代码:
string filename = Path.Combine(ApplicationData.Current.LocalFolder.Path, "data.db");
One small roadblock removed, many more to go! 一个小路障被移除,还有更多去!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.