c# - 在 C# 上打开 SQLite 连接时出错?

标签 c# database visual-studio sqlite memory

我正在尝试连接并从 SQLite 数据库表中选择数据,但它在 con.Open() 行中向我显示此错误:

An unhandled exception of type 'System.AccessViolationException' occurred in SQLite.NET.dll

Attempted to read or write protected memory. This is often an indication that other memory is corrupt

这是我的代码:

SQLiteConnection con = new SQLiteConnection("Data Source = db.sqlite; Version=3;");
con.Open();

SQLiteCommand command = new SQLiteCommand("Select * from [user] where login=@login and password=@password", con);

command.Parameters.Add("@login", textBox1.Text);
command.Parameters.Add("@password", textBox2.Text);

我还添加了对 SQLite .dll 的引用。

这个错误的原因是什么?

最佳答案

问题是您尝试将数据库嵌入到程序集中。这不是一个好主意,因为该内存是只读的。

关于c# - 在 C# 上打开 SQLite 连接时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44371016/

相关文章:

c# - 如何获取完全加载的 HTML 页面代码

c# - Windows Phone 7 是否支持动态关键字?

mysql - 如何为国际网站设计数据库?

c# - tableadaptor - 删除行

c# - Visual Studio 2017 propfull 片段但带有 .this

visual-studio-2010 - 如何执行与从Powershell中发布Visual Studio中的发布完全相同的功能

c# - 无法加载计数器名称数据,因为索引无效 - 异常

c# - 避免泄露 CSHTML 和 javascript 的源代码

mysql - 如何合并连接表结果中的列?

visual-studio - VS2010 - 2 个项目,1 个解决方案 - 在 1 个实例下调试两者