Your dog needs to be seen by a vet and given a good, strong veterinary anthelmintic like Nemex-2. A follow-up worming in two or three weeks should take care of the problem, but an infestation this bad is really taking a toll on the dog's health, so you need to act ASAP on this.
Ghilly
Good Lord! That is a really BAD infestation, and your dog needs veterinary assistance to get of them. Your dog is probably malnourished with that amount of worms, so please don't wait. This is not a problem for an over-the-counter treatment.