Guest User

Untitled

a guest
Jan 23rd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. try
  2. {
  3. using (SqlConnection con = new SqlConnection(connstring2))
  4. {
  5. con.Open();
  6. using (SqlCommand command = new SqlCommand("DELETE FROM Customer WHERE Id = '" + item + "'", con))
  7. {
  8. command.ExecuteNonQuery();
  9. using (StreamWriter sw = File.AppendText(Application.StartupPath + @"PurgeSucceed.Log"))
  10. {
  11. sw.WriteLine(CustomerIdentifier + " was deleted");
  12. }
  13. }
  14. con.Close();
  15. }
  16. }
  17. catch (Exception ex)
  18. {
  19. using (StreamWriter sw = File.AppendText(Application.StartupPath + @"PurgeFail.Log"))
  20. {
  21. sw.WriteLine(CustomerIdentifier + " has a relationship somewhere in the database.");
  22. }
  23. }
Add Comment
Please, Sign In to add comment