Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- using (SqlConnection con = new SqlConnection(connstring2))
- {
- con.Open();
- using (SqlCommand command = new SqlCommand("DELETE FROM Customer WHERE Id = '" + item + "'", con))
- {
- command.ExecuteNonQuery();
- using (StreamWriter sw = File.AppendText(Application.StartupPath + @"PurgeSucceed.Log"))
- {
- sw.WriteLine(CustomerIdentifier + " was deleted");
- }
- }
- con.Close();
- }
- }
- catch (Exception ex)
- {
- using (StreamWriter sw = File.AppendText(Application.StartupPath + @"PurgeFail.Log"))
- {
- sw.WriteLine(CustomerIdentifier + " has a relationship somewhere in the database.");
- }
- }
Add Comment
Please, Sign In to add comment