我正在尝试制作一个使用帐号更新帐户昵称的按钮,但出现错误。
private void change_nickname_Click(object sender, EventArgs e)
{
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query = "update customers set [CustomerCode]='" + customercode.Text + "',[CustomerName]='" + customername.Text + "',[Address]='" + customeraddress.Text + "',[PhoneNumber]='" + customerphone.Text + "',[Account]='" + Account + "',[AccountNickname]='" + accountnickname.Text + "',[Overdraft]='" + overdraft.Text + "' where AccountNumber=" + accountnumber.Text + "";
MessageBox.Show(query);
command.CommandText = query;
command.ExecuteNonQuery();
MessageBox.Show("Data updated successfuly!");
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex);
}
connection.Close();
}