I check in various tables whether the value to be deleted exists. Everything is working correctly, but I would like to program a message that informs the user that the entry cannot be deleted because it is still present in another table. I would like to ask you for your support. This is my query:
con.Open();
using (cmd = new SqlCommand("delete from Clinic where C_ID=@C_ID AND NOT EXISTS (SELECT * FROM Document_Type AS o WHERE o.C_ID=@C_ID)", con))
{
cmd.Parameters.AddWithValue("@C_ID", klinikUD.Value);
cmd.ExecuteNonQuery();
con.Close();
}