-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