SQL逻辑错误或缺少数据库没有这样的表

Jet*_*ack 9 c# sqlite

我试图从Condition本地sqlite数据库中的表中读取所有数据.但是我收到此错误:

SQL逻辑错误或缺少数据库没有这样的表

数据库与调用它的文件位于同一目录中.

这是我的代码:

SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=myDatabase.sqlite;Version=3;");
m_dbConnection.Open();

try
{
    string sql = "select * from Condition";
    SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);

    SQLiteDataReader reader = command.ExecuteReader();

    while (reader.Read())
        Console.WriteLine("Name: " + reader["name"] + "\tScore: " + reader["id"]);

    Console.ReadLine();
    return null;
}
catch (Exception exc)
{
    return null;
}
finally
{
    m_dbConnection.Close();
}
Run Code Online (Sandbox Code Playgroud)

Jet*_*ack 9

我通过使用绝对路径而不是相对路径来解决问题.感谢Eternal21 /sf/answers/1405863371/


Cri*_*oni 5

该数据库应位于您的bin文件夹中,否则请指定.sqlite文件的绝对路径。