我想讀本地SQLite數據庫中的表Condition
的所有數據。但是我得到這個錯誤:SQL邏輯錯誤或缺失數據庫沒有這樣的表
SQL logic error or missing database no such table
數據庫位於與調用它的文件相同的目錄中。
這是我的代碼:
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();
}
這是你使用數據庫文件的確切路徑嗎? – horHAY 2015-03-25 08:12:35
我建議你爲你的數據源嘗試一個完全合格的路徑(比如'C:/whatever/myDatabase.sqlite'來檢查你的代碼是否真的找到了數據庫文件,你的語句和調用它的*文件* 「聽起來對我來說很可疑 - 你如何運行你的代碼? – 2015-03-25 08:18:17