【问题标题】:Sqlite Setting Serialized mode throws ExceptionSqlite设置序列化模式抛出异常
【发布时间】:2017-03-28 07:28:06
【问题描述】:

我正在尝试通过设置 FullMutex 模式来创建连接。这是抛出 SQLiteException - 无法打开文件 db 路径滥用。

_DBConn = new SQLiteConnection(new SQLitePlatformWinRT(), dbpath,SQLite.Net.Interop.SQLiteOpenFlags.FullMutex);

如何解决这个问题?

【问题讨论】:

  • 没有FullMutex 标志是否可以工作?
  • 是的,它可以在没有标志的情况下工作
  • 你能把你的错误堆栈放在这里吗?
  • 我的异常消息“无法打开数据库文件:dbpath(误用)”和堆栈跟踪“在 SQLite.Net.SQLiteConnection..ctor(ISQLitePlatform sqlitePlatform, String databasePath, SQLiteOpenFlags openFlags, Boolean storeDateTimeAsTicks, IBlobSerializer 序列化程序, IDictionary2 tableMappings, IDictionary2 extraTypeMappings, IContractResolver 解析器)"
  • 这是发生在多线程应用程序还是 Web 应用程序中?如果您使用导致问题的相同代码创建新的控制台应用程序,是否会出现同样的问题?

标签: c# sqlite uwp


【解决方案1】:

您没有指定强制标志(SQLITE_OPEN_READONLY 或 SQLITE_OPEN_READWRITE)。您必须指定它们。

修改打开命令(假设db不存在,必须创建):

_DBConn = new SQLiteConnection(new SQLitePlatformWinRT(), dbpath, 
  // optional - if you want to create new db    
  SQLite.Net.Interop.SQLiteOpenFlags.Create |   
  SQLite.Net.Interop.SQLiteOpenFlags.ReadWrite | 
  SQLite.Net.Interop.SQLiteOpenFlags.FullMutex);

完整参考: https://sqlite.org/c3ref/open.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-06
    • 1970-01-01
    相关资源
    最近更新 更多