I am building a Point of Sales system in C# and I am passing the data from the Interface through an object to the database.
The update function throws a Syntax Error in cmd.CommandText every time I try to update.
private void btnUpdate_Click(object sender, EventArgs e) //UPDATE FUNCTION//
{
user_management_system user_mgnt = new user_management_system();
user_mgnt.Username = txt_userName.Text;
user_mgnt.Password = txt_password.Text;
user_mgnt.First_name = txt_firstName.Text;
user_mgnt.Last_name = txt_lastName.Text;
user_mgnt.Nationality = txt_nationality.Text;
user_mgnt.Email = txt_email.Text;
user_mgnt.Age = (txt_age.Text);
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "UPDATE userlogin SET password = ('"+ user_mgnt.Password + "',first_name='" + user_mgnt.First_name + "',last_name='" + user_mgnt.Last_name + "',age='" + user_mgnt.Age +
"',nationality='" + user_mgnt.Nationality + "',email='" + user_mgnt.Email + "', WHERE username ='"+ user_mgnt.Username+ "')";
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Data has been successfuly updated");
displaydata();