Mohammed Salim

Mohammed Salim

  • NA
  • 56
  • 3.1k

Update Command not working

Apr 19 2018 2:50 PM
Thanks for the help in advance.
 
Im trying to use update query in C#
 
command is getting executed even if I use incorrect values is given.
 
Instead giving error . It shows command successful.
 
Pls find the code
  1. protected void Button1_Click(object sender, EventArgs e)  
  2. {  
  3. try  
  4. {  
  5. con.Open();  
  6. cmd = new SqlCommand("update Comcast_AvayaID set Status='Inactive' where Employee_Id='" + TxtEMPID.Text + "' and AvayaID ='" + TxtAvayaID.Text + "'", con);  
  7. cmd = new SqlCommand("UPDATE Avaya_Id SET Status = 'UnAssigned' where Avaya_ID ='" + TxtAvayaID.Text + "'", con);  
  8. cmd.ExecuteNonQuery();  
  9. LBLSuccess.Visible = true;  
  10. LBLSuccess.Text = "Deactivation Successfull";  
  11. con.Close();  
  12. }  
  13. catch (SqlException ex)  
  14. {  
  15. LBLSuccess.Visible = true;  
  16. LBLSuccess.Text = "Deactivation Unsuccessfull";  
  17. }  

Answers (1)