public string Delete(DeleteUser d) { string msg = ""; SqlConnection con = new SqlConnection("Data Source=ARIFBUDIMANAR;Initial Catalog=crudDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"); con.Open(); SqlCommand cmd = new SqlCommand("delete UserTab where UserID = @UserID", con); cmd.Parameters.AddWithValue("@UserID", d.UID); int res = cmd.ExecuteNonQuery(); if (res == 1) { msg = "Berhasil Hapus"; } else { msg = "Gagal Hapus"; } return(msg); }
public string Delete(DeleteUser d) { string msg = ""; SqlConnection con = new SqlConnection("Data Source=DESKTOP-Q6TINDB; Initial Catalog=WCF;Persist Security Info=True;User ID=sa; Password=123ricki"); con.Open(); SqlCommand cmd = new SqlCommand("delete UserTab where UserID = @UserID", con); cmd.Parameters.AddWithValue("@UserID", d.UID); int res = cmd.ExecuteNonQuery(); if (res == 1) { msg = "Successfully deleted"; } else { msg = "Failed to deleted"; } return(msg); }