此代码有什么问题?我所做的一切,但我仍然得到UPDATE语句中的语法错误
语法错误在UPDATE语句
请帮助。先谢谢你。
OleDbConnection conn = default(OleDbConnection);
OleDbCommand cmd = default(OleDbCommand);
conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=DemoDB.accdb");
string sql = "UPDATE APPOINTMENTS Set ([CustomerID]=" + txtCid.Text + ", [DateTime]= " + dateTimePicker5.Text + ", [Time]=" + txtNewTime.Text + " WHERE [CustomerID]=" + txtCid.Text + ");";
conn.Open();
cmd = new OleDbCommand(sql, conn);
cmd.ExecuteNonQuery();//execute the sql command
MessageBox.Show("Appointment Changed Successful");
//close the connectionstring
conn.Close();
使用参数,你将免于这个问题(和其他人) – Steve
我不擅长使用参数你会帮助这么做,请。 –
此链接显示使用参数的示例http://stackoverflow.com/questions/15126427/oledb-update-command –