When I run my program and try to update it, it updates all the columns to the new data in textboxes I don't know how to tell it to do it for the certain username which is in a textbox (txtUsernameUser.Text) table name is UserData primary key is Username. I just want to say thanks in advance for your time
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=E:\Graded unit Dev\BlackMarch\BlackMarch\bin\Debug\DataBaseBM.mdf;Integrated Security=True;Connect Timeout=30");
SqlCommand cmd = new SqlCommand("UPDATE UserData SET Username = @Username, Password = @Password, FirstName = @Firstname, Surname = @Surname, Age = @Age, Gender = @Gender, Mobile = @Mobile, Email = @Email", con);
con.Open();
cmd.Parameters.AddWithValue("@Username", txtUsernameUser.Text);
cmd.Parameters.AddWithValue("@Password", txtboxPass.Text);
cmd.Parameters.AddWithValue("@FirstName", txtboxFN.Text);
cmd.Parameters.AddWithValue("@Surname", txtboxSurname.Text);
cmd.Parameters.AddWithValue("@Age", txtboxAge.Text);
cmd.Parameters.AddWithValue("@Gender", txtboxGender.Text);
cmd.Parameters.AddWithValue("@Mobile", txtboxMobile.Text);
cmd.Parameters.AddWithValue("@Email", txtboxEmail.Text);
cmd.ExecuteNonQuery();
con.Close();
WHEREclause inside your update.AddWithValue()- it can lead to unexpected and surprising results...