I used to have this problem. I went on a cleanse for a week and then slowly added foods back into my diet paying attention until I noticed I was farting again. In the end I ha to cut out most dairy, most bread products and all fast food/junk food. No more gass, no more pain!
I suggest you do the same?