I am trying to make a button that updates account nickname using the account number but Im getting an error.
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();
}
Yeah the problem was solved guys thank for all the help. The problem was here.
where AccountNumber=" + accountnumber.Text + "";
MessageBox.Show(query);
I changed this to
where AccountNumber='" + accountnumber.Text + "'";
MessageBox.Show(query);
And it worked somehow.