我正在尝试连接并从 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/