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();
}
Willi Mentzel
27.4k20 gold badges112 silver badges119 bronze badges
asked Mar 25, 2015 at 8:07
2
The database should be located in your bin
folder, or else specify the absolute path to the .sqlite file.
answered Mar 25, 2015 at 8:20
0
I received the same error message on a linux system. When the database was created, the program was running as root: when the error occurred, the program was running as me. Basically, I didn’t have write permission on the file.
answered Mar 12, 2021 at 12:36
JavaLatteJavaLatte
3665 silver badges18 bronze badges
Всем привет!
Хочу записать данные в SQLite, а она ругается:
SQL logic error or missing database
near «integer»: syntax error
Не пойму в чем дело.
Проверил запрос. Вроде все правильно:
SQL | ||
|
Сам код такой:
C# | ||
|
Таблица создавалась так:
C# | ||
|
С моей точкт зрения синтаксис правильный. С MySQL работал так много раз. Смотрел на документацию SQLite, вроде синтаксис такой же.
В чем может быть ошибка?
- Remove From My Forums
-
Question
-
SQLiteCommand command = new SQLiteCommand(connection); command.CommandText = "UPDATE glasba SET Naslov ='" + textBox1.Text+"', Izvajalec = '"+textBox2.Text+"', Zanr ='"+textBox3.Text+"', Ocena ='"+textBox4.Text+"') WHERE (Naslov = '" + imes + "') AND (Izvajalec = '" + imea + "') "; connection.Open(); command.ExecuteNonQuery(); connection.Close(); this.Hide();
System.Data.SQLite.SQLiteException
HResult=0x80004005
Message=SQL logic error or missing database
near «=»: syntax errorI dont know what to do, this error getting up even though i tried adding parameters and so on…
Answers
-
Hi
Thank you for posting here.
According to your description, you want to solve the error that ’ System.Data.SQLite.SQLiteException’.
You could try the following code.
SQLiteConnection connection = new SQLiteConnection(@"Data Source = MyDatabase.sqlite"); connection.Open(); string sql = String.Format("UPDATE glasba SET naslov ='{0}', izvajalec='{1}',zanr='{2}',ocena='{3}' ,review='{4}' WHERE naslov = 'test1' and izvajalec='test2'",textBox1.Text,textBox2.Text,textBox3.Text,textBox4.Text,textBox5.Text); SQLiteCommand command = new SQLiteCommand(sql,connection); command.ExecuteNonQuery(); connection.Close();
Result:
Best Regards,
Jack
MSDN Community Support
Please remember to click «Mark as Answer» the responses that resolved your issue, and to click «Unmark as Answer» if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.-
Proposed as answer by
Tuesday, March 26, 2019 5:14 PM
-
Unproposed as answer by
Cherkaoui.Mouad
Tuesday, March 26, 2019 5:15 PM -
Marked as answer by
Twinkiiee
Wednesday, April 3, 2019 2:43 PM
-
Proposed as answer by
Loading
Loading