I am trying to read all data from the table Condition
in a local sqlite database. However I am getting this error:
SQL logic error or missing database no such table
The database is located in the same directory as the file that's calling it.
This is my code:
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();
}
I have fixed the issue by using a absolute path instead of a relative path. thanks to Eternal21 https://stackoverflow.com/a/20083762/3483812
The database should be located in your bin
folder, or else specify the absolute path to the .sqlite file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With