gpt4 book ai didi

c# - Sqlite 设置序列化模式抛出异常

转载 作者:行者123 更新时间:2023-11-30 21:41:42 25 4
gpt4 key购买 nike

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

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

如何解决这个问题?

最佳答案

您没有指定强制标志(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);

Full reference: https://sqlite.org/c3ref/open.html

关于c# - Sqlite 设置序列化模式抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43063192/

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