public string deleteString(string parentId, string user) { string response = ""; try { parentDelete del = new parentDelete(); del.parentId = new Guid(parentId); del.user = new Guid(user); response = delete(del); } catch { response = "Error"; } return(response); }
public string delete(parentDelete use) { string response = "Error"; SqlConnection con = new SqlConnection(data); SqlCommand cmd = new SqlCommand("DELETE FROM courseParent WHERE parentId = @parentId", con); cmd.Parameters.AddWithValue("@parentId", use.parentId); con.Open(); try { cmd.ExecuteNonQuery(); response = "Success"; } catch (SqlException ex) { response = ex.ToString(); } con.Close(); return(response); }