![](/img/trans.png)
[英]Create SQLite database file with SQLite-net on Windows Phone 8
[英]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.