There seems to be an error in my query somewhere but for the life of me I cant seem to find it, if anyone could take a look that would be appreciated. Ive tried googling to see if anyone has had the same issue but no luck yet. Sorry if its a duplicate.
public static void InsertMake()
{
try
{
using (var conn = new SqlCeConnection(_connectionstring))
{
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
using (var command = new SqlCeCommand(@"INSERT INTO MAKE(description,lastupdatedone,is_deleted,on_server) VALUES (@Description, @DateTime, @Is_deleted, @On_server", conn))
{
command.Parameters.AddWithValue("@Description", Program.Form_mmm.textBoxMake.Text);
command.Parameters.AddWithValue("@DateTime", DateTime.Now);
command.Parameters.AddWithValue("@Is_deleted", 0);
command.Parameters.AddWithValue("@On_server", 0);
command.ExecuteNonQuery();
conn.Close();
}
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
The error message is
(0x80004005) There was an error parsing the query. [token line number = 1, token line offset = 114, token in error = @On_server]
You're missing the closing parenthesis after VALUES, but you should probably include the error message to be 100% sure that's the problem.
Try changing this line
using (var command = new SqlCeCommand(@"INSERT INTO MAKE(description,lastupdatedone,is_deleted,on_server) VALUES (@Description, @DateTime, @Is_deleted, @On_server", conn))
to this
using (var command = new SqlCeCommand(@"INSERT INTO MAKE(description,lastupdatedone,is_deleted,on_server) VALUES (@Description, @DateTime, @Is_deleted, @On_server)", conn))
User contributions licensed under CC BY-SA 3.0