gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 17:03:23 25 4
gpt4 key购买 nike

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

似乎数据库文件从未写入 IsoStore(如 IsoStoreSpy 所示)。不会抛出任何异常。

我尝试了以下方法:

  • 将 SQLite for Windows Phone 从 3.7.1.16 升级到 3.8.0.2(一个极其痛苦的过程)

  • 按照 Working with sqlite in windows phone 8 a sqlite net version for mobile 中的建议提供绝对和相对路径.

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

  • 其他随机的东西

这是我的代码(我正在使用 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");

移除了一个小障碍,还有更多障碍!

关于c# - 在 Windows Phone 8 中,SQLite 可以工作但不会将数据库文件写入 IsoStore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18661483/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com