我刚刚开始做示例应用程序,只调用我的sqlite数据库上的一些表,我已设法解决发生在我身上的其他问题,除了这个!虽然我搜索了关于连接字符串和权限问题的建议解决方案,并且所有似乎对我的许可似乎无效,我添加了所有用户完全控制并仍然相同的错误.下面是我试图执行的代码:
// calling function
void getrecords2()
{
MySqlLite.DataClass ss = new MySqlLite.DataClass();
DataTable dt = ss.selectQuery("select * from english_words");
}
//the SQLite class that execute the code
using System.Data;
using System.Data.SQLite;
namespace MySqlLite
{
class DataClass
{
private SQLiteConnection sqlite;
public DataClass()
{
//This part killed me in the beginning. I was specifying "DataSource"
//instead of "Data Source"
sqlite = new SQLiteConnection(@"Data Source=C:\testwork\db\MrPick.sqlite3.db;Version=3;FailIfMissing=True");
}
public DataTable selectQuery(string query)
{
SQLiteDataAdapter ad;
DataTable dt = new DataTable();
try
{
SQLiteCommand cmd; …Run Code Online (Sandbox Code Playgroud) 除了 IIS 上的“无法打开数据库文件”之外,我似乎无法从 SQLite 中获得任何信息。我确信 SQLite 的错误消息和 Oracle 的错误消息一样粗暴。
Full control以下用户授予对 App_Data 和数据库文件的访问权限:IIS_IUSRS、IUSRS、DefaultAppPool和Everyone。我查看过:
SQLite问题“无法打开数据库文件”(该问题自动消失为用户)和许多其他类似的问题,其中大多数是通过更改权限、更改为可写目录(App_Data应该是可写的,不是吗?)或者将相对路径更改为绝对路径(应该|DataDirectory|解析为)。
<connectionStrings>
<add name="sqlite" connectionString="Data Source=|DataDirectory|\datatables.sqlite;Version=3;" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>Unable to open the database file</ExceptionMessage>
<ExceptionType>System.Data.SQLite.SQLiteException</ExceptionType>
<StackTrace>
at System.Data.SQLite.SQLite3.Open(String strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool) at System.Data.SQLite.SQLiteConnection.Open() at AjaxSource.Models.Database.query(String sql, Dictionary`2 parameters) in D:\Tools\Dropbox\Projects\myprojects\AjaxSource\AjaxSource\Models\Database.cs:line …Run Code Online (Sandbox Code Playgroud)