以下代码给出了一个语法错误。我不知道如何解决这个问题。Sqlite“更新”C#语法错误
的错误
{ “SQLite的错误\ r \ nnear \” MYTEXT \ “:语法错误”}
我的代码
string dataSource = "Database.s3db";
SQLiteConnection connection = new SQLiteConnection();
connection.ConnectionString = "Data Source=" + dataSource;
connection.Open();
SQLiteCommand command = new SQLiteCommand(connection);
command.CommandText = ("update Example set Info ='" + textBox2.Text + ", Text ='"+textBox3.Text + "where ID ='" + textBox1.Text +"'");
command.ExecuteNonQuery();
为了避免这种错误(和SQL注入)的,你应该使用的查询参数,而不是动态创建的SQL命令字符串。 – svick 2012-03-04 15:37:45
@ user1248067:*请*不要按照原样使用接受的答案。你应该*真的,真的*使用参数化的SQL。 – 2012-03-04 15:47:52