I'm receiving this error '{"SQLite error\r\nnear \"Values\": syntax error"}'. with the following block of code.
using (SQLiteConnection connection = new SQLiteConnection())
{
connection.ConnectionString = ConnectionString;
connection.Open();
using (SQLiteCommand insertSQL = new SQLiteCommand(connection))
{
insertSQL.CommandText = "INSERT INTO BetaValues(Name, Values) VALUES(@param1, @param2)";
//insertSQL.CommandType = CommandType.Text;
insertSQL.Parameters.Add("@param1", DbType.String).Value = beta.Name.ToString();
insertSQL.Parameters.Add("@param2", DbType.String).Value = beta.ValuesXML.ToString();
insertSQL.ExecuteNonQuery();
}
The data definition of my table is the following.
CREATE TABLE BetaValues (
idBetaValues INTEGER PRIMARY KEY,
Name STRING (20) NOT NULL
UNIQUE,
[Values] TEXT UNIQUE
);
I've been trying to wrap my head around this error, but I can't find the reason why I'm receiving the previous error.
Valuesis a reserved word in SQL. You have to escape the name in your INSERT statement the same way you did in your CREATE statement.