C# 无法读取数据库文件asp.net c

C# 无法读取数据库文件asp.net c,c#,asp.net,sql,visual-studio-2010,C#,Asp.net,Sql,Visual Studio 2010,我不知道为什么在代码中给我这个错误: 无法读取数据库文件 我在da.filldt行得到这个错误 我试图从我的数据库中选择并在我的DayPilotScheduler1中显示它们 private void loadResources() { DayPilotScheduler1.Resources.Clear(); string roomFilter = "0"; if (DayPilotScheduler1.ClientState["filter"] != null)

我不知道为什么在代码中给我这个错误:

无法读取数据库文件

我在da.filldt行得到这个错误

我试图从我的数据库中选择并在我的DayPilotScheduler1中显示它们

private void loadResources()
{
    DayPilotScheduler1.Resources.Clear();

    string roomFilter = "0";
    if (DayPilotScheduler1.ClientState["filter"] != null)
    {
        roomFilter = (string)DayPilotScheduler1.ClientState["filter"]["room"];
    }
    SQLiteConnection con = new SQLiteConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=Korisnik;Integrated Security=True");
    SQLiteDataAdapter da = new SQLiteDataAdapter("SELECT [id], [name], [beds], [bath] FROM [RoomDetails] WHERE beds = @beds or @beds = '0'", con);
    da.SelectCommand.Parameters.AddWithValue("beds", roomFilter);
    DataTable dt = new DataTable();
    da.Fill(dt);

    foreach (DataRow r in dt.Rows)
    {
        string name = (string)r["name"];
        string id = (string)r["id"];
        string bath = (string)r["bath"];
        int beds = Convert.ToInt32(r["beds"]);
        string bedsFormatted = (beds == 1) ? "1 bed" : String.Format("{0} beds", beds);

        Resource res = new Resource(name, id);
        res.Columns.Add(new ResourceColumn(bedsFormatted));
        res.Columns.Add(new ResourceColumn(bath));

        DayPilotScheduler1.Resources.Add(res);
    }
}

根据连接字符串,您连接的是SQL Server Express数据库,而不是SQLite数据库


使用SqlConnection而不是SQLiteConnection以及相应的DataAdapter等。

根据连接到SQL Server Express数据库而不是SQLite数据库的连接字符串


使用SqlConnection而不是SQLiteConnection以及相应的DataAdapter等。

每当出现这种类型的错误时,connectionstring中可能会出现错误,因此请跟踪web.config文件。
在上面的代码中,您提到了Sqliteconnection,它应该是Sqlconnection,并在代码中进行了相应的更改。

每当出现这种类型的错误时,connectionstring中可能会出现错误,因此请跟踪您的web.config文件。
在上面的代码中,您提到了Sqliteconnection,它应该是Sqlconnection,并在代码中进行了相应的更改。

您是否可以发布完整的异常>很抱歉没有将此作为注释发布,但没有足够的代表:使用Sqlconnection,而不是Sqliteconnection。您使用的是windows 7吗?尝试以管理员身份运行Visual Studio…并使用配置文件存储连接字符串!您能告诉我如何在配置文件中放置连接字符串,然后如何在sql语句中调用连接字符串吗?您能发布完整的异常>很抱歉没有将此作为注释发布,但没有足够的代表:使用SqlConnection,而不是SQLiteConnection。您使用的是windows 7吗?尝试以管理员身份运行Visual Studio…并使用配置文件存储连接字符串!您能告诉我如何在配置文件中放置连接字符串,然后如何在sql语句中调用连接字符串吗?