【发布时间】:2015-03-25 08:07:12
【问题描述】:
我正在尝试从本地 sqlite 数据库中的表 Condition 中读取所有数据。但是我收到了这个错误:
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();
}
【问题讨论】:
-
这是您用于数据库文件的确切路径吗?
-
我建议你为你的数据源尝试一个完全限定的路径(比如'C:/whatever/myDatabase.sqlite'来检查你的代码是否真的找到了数据库文件。你的声明“与file 调用它”对我来说听起来很可疑 - 你是如何运行你的代码的?