【发布时间】:2020-02-13 15:41:29
【问题描述】:
我正在使用此官方 MSDN 教程的 this 部分:Use a SQLite database in a UWP app 但我收到以下错误:
备注:网上有很多与这个问题相关(或类似)的帖子,但似乎都没有解决办法。这些帖子中的大多数都是几年前的,所以我认为这个问题现在已经解决了。此外,上面提到的教程也是使用.NET Standard 类库项目。并且有关该问题的在线帖子没有涉及.NET Standard。所以,我想知道这个问题是否是由使用 .NET Standard 库引起的。无论如何,我们将不胜感激。
SQLite 错误 14:“无法打开数据库文件”
this 代码的 db.Open() 行发生错误:
public static void InitializeDatabase()
{
using (SqliteConnection db =
new SqliteConnection("Filename=sqliteSample.db"))
{
db.Open();
String tableCommand = "CREATE TABLE IF NOT " +
"EXISTS MyTable (Primary_Key INTEGER PRIMARY KEY, " +
"Text_Entry NVARCHAR(2048) NULL)";
SqliteCommand createTable = new SqliteCommand(tableCommand, db);
createTable.ExecuteReader();
}
}
注意事项:
- 上述代码正下方的行显示为:
This code creates the SQLite database and stores it in the application's local data store.这意味着应用应该有权访问该本地数据存储。 - 我在
Windows 10上使用VS2019的最新版本16.3.5。项目的目标版本选择为Windows 10 1903,最小版本选择为Windows 10 1903
更新
【问题讨论】: