Given the code :
SQLiteCommand cmd = new SQLiteCommand("UPDATE \"Category\" SET \"name\"=?name, \"description\"=?description, \"color\"=?color, \"active\"=?active, \"parent\"=?parent WHERE \"id\"=?id", sql);
cmd.Parameters.Add("?id", DbType.Int32).Value = _id;
cmd.Parameters.Add("?name", DbType.String).Value = _name;
cmd.Parameters.Add("?description", DbType.String).Value = _description;
cmd.Parameters.Add("?color", DbType.Int32).Value = _color;
cmd.Parameters.Add("?active", DbType.Boolean).Value = _active;
cmd.Parameters.Add("?parent", DbType.Int32).Value = _开发者_如何学JAVAparent;
cmd.Prepare();
cmd.ExecuteNonQuery();
We have the problem that the last line throws
SQLite error near "name": syntax error
which IMO is nonsense. Something else must be going on. The table is connected and open (as I can read from the table just fine) and everything else works just great. It just can't seem to handle this simple update for some reason.
EDIT: OK. I tried taking the name field out entirely and still no dice. I just get the error on the description field then. It's definitely not a keyword issue.
Have you tried the following?
cmd.Parameters.Add("@id", DbType.Int32);
cmd.Parameters.Add("@name", DbType.String);
...
cmd.Parameters["@id"].Value = _id;
cmd.Parameters["@name"].Value = _name;
...
Use brackets around field names in the sql syntax, as they can conflict with reserved words too. Brackets will eliminate this problem. I am not sure but both id and name could be reserved words.
精彩评论