It might be something he ate that didn't agree with him. You can give your dog some pepcid or Zantac. Read about Pepcid dosages and usage information here:
Zantac can be given to a dog at .25 to 1mg per pound every 8-12 hours. Read about usage here:
Wait an hour after the medication and try feeding him a small amount of boiled chicken and rice. If he keeps that down, you can feed him another small portion. As long as he does well, you can gradually put him back on his own food and monitor his bowel movements to ensure they firm up and no longer contain blood.
If he continues to vomit, you can try witholding all food and water till morning and then try again with small portion of chicken and rice. If there is no improvement, you will need to have him seen. If he has had any fatty foods like ham, duck, and bacon, he may have pancreatitis. Symptoms of pancreatitis vary but include vomiting, diarrhea, anorexia, weakness or collapse, dehydration, shock, fever, depression, and upper abdominal pain. A dog may indicate abdominal pain by acting restless, panting, crying or wincing when picked up, shaking, standing with an arched back, or lying with the front end down and the rear end elevated
You can read about it in detail here:
Other causes could include parasites such as worms or a protozoan infection such as coccidia or giardia. Most of these start with diarrhea, but since they can have these symptoms, I have included them. Here are sites on worms, coccidia and giardia, which you may find informative.
If your dog refuses to eat, then it is possible your dog has hemorrhagic gastroenteritis (HGE) . HGE is very serious and life threatening. You can read about it here:
If that is the case, your dog will need to see a vet immediately. I hope this information has been helpful to you.