Benjamin Ashton

Benjamin Ashton

  • NA
  • 15
  • 7.4k

Updating SQL from C#, changing all the data

Jul 12 2012 2:23 PM
I am using the below code to try and update records within my SQL server but having problems, it is updating all the records to what I want it to change too. It would be great if someone could steer me in the right direction.

         da.UpdateCommand = new SqlCommand("UPDATE userInfo SET Username = @USERNAME, Password = @PASSWORD", cs);
            da.UpdateCommand.Parameters.Add("@USERNAME", SqlDbType.VarChar).Value = txtUsername.Text;
            da.UpdateCommand.Parameters.Add("@PASSWORD", SqlDbType.VarChar).Value = txtPassword.Text;

            cs.Open();
            da.UpdateCommand.ExecuteNonQuery();
            cs.Close();

            dgUpdate();


Answers (7)