-1
我的系统不会更新,和它显示这个错误,我不知道该怎么办。有什么建议么?这里是我的代码错误数据库更新查询
private void btnupdate_Click(object sender, EventArgs e)
{
com.Connection = con;
con.Open();
string query = "UPDATE [Promissory] SET [pdate] = ?,[Edpno] = ?, [gradingperiod] = ?, [pamount] = ?, [reasons] = ?, [syid] = ? WHERE Promissoryno = ?";
var accessUpdateCommand = new OleDbCommand(query, con);
accessUpdateCommand.Parameters.AddWithValue("pdate", txtdate.Text);
accessUpdateCommand.Parameters.AddWithValue("Edpno", txtedpno.Text);
accessUpdateCommand.Parameters.AddWithValue("gradingperiod", txtgradeperiod.Text);
accessUpdateCommand.Parameters.AddWithValue("pamount", txtamount.Text);
accessUpdateCommand.Parameters.AddWithValue("reasons", txtreasons.Text);
accessUpdateCommand.Parameters.AddWithValue("syid", txtsyid.Text);
accessUpdateCommand.Parameters.AddWithValue("Promissoryno", txtpromiseno.Text); // Replace "123" with the variable where your ID is stored. Maybe row[0] ?
da.UpdateCommand = accessUpdateCommand; //This line here is the error
da.UpdateCommand.ExecuteNonQuery();
con.Close();
}
,准确错误是什么? –
哪一行是错误? 'com','con'或'da'的 –
至少一个变量为空。在方法的第一行设置一个断点并检查它们。 – Viper