If your dog is showing symptoms of heartworms, DO NOT give them a dose of the preventative medicine without first checking to see if they are full of actual adults (blood test and quick check under a microscope).
If your dog has a full on heartworm infestation and you give them the preventative medicine, most likely they WILL die of heart failure.
Essentially all the adult worms do a sudden die off and clog the heart and that's done and pretty much the end & not a pretty way for your dog to go out.
Instead, you need to do the treatment where they put them on a different meds that specifically targets only the eggs and early larvae, that then kills off the future generations slowly and as the adults age out and die in a slower manner, the dog's body can flush the carcasses out.
You should always have your dogs on heartworm prevention medicine, it's too risky not to have them on it, compared to the cost of the meds.
I learned the above the hard way because the local vet was a total lazy idiot.
This is exactly what has to be done. We dose our dogs every two weeks. It IS a hard lesson to learn. Sorry for your experience.