Fasting may exacerbate gastric pains but it's not reason for it. You need to get rid of h pylori bacteria.
Nexium tablets may work. If acute cases, take twice a day. After a while, symptoms may disappear. Just my thoughts based on anothers experience.