相关疑难解决方法(0)

SQLIte无法打开数据库

我刚刚开始做示例应用程序,只调用我的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)

c# sqlite

4
推荐指数
2
解决办法
2万
查看次数

“无法打开数据库文件”(警告:宽错误)

除了 IIS 上的“无法打开数据库文件”之外,我似乎无法从 SQLite 中获得任何信息。我确信 SQLite 的错误消息和 Oracle 的错误消息一样粗暴。

  • Visual Studio 2010/IIS Express 中的预部署我可以读取和写入该文件。
  • 当我尝试使用部署到 IIS7.5 的相同 VS2010 项目来读取/写入它时,所有“创建”、“读取”和“写入”命令都失败。
  • 当我通过项目部署数据库文件并尝试读取它时,也会发生同样的情况。
  • 我已向Full control以下用户授予对 App_Data 和数据库文件的访问权限:IIS_IUSRSIUSRSDefaultAppPoolEveryone

我查看过: 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)

sqlite asp.net-mvc system.data.sqlite iis-7.5 asp.net-mvc-4

2
推荐指数
1
解决办法
5319
查看次数