This has happens to me a lot. So your are constipated. Well sometimes I bet you are in public and you have to fart. But you hold it in. That's ok. But when you have it in there a while it builds up gas in you stomach and it's very painful. It's just built up gas. When you are somewhere alone. Let it out then it will stop. I don't know if that's why but that can happen. Comment back to tell me if I'm right
According to Mayo Clinic, the sharp stabbing stomach pains could be caused by an intestinal obstruction, food poisoning or irritable bowel syndrome. Pelvic inflammatory disease, acute pancreatitis or appendicitis could also be causing the problem. You need to seek medical attention as soon as possible so that the cause can be diagnosed and treatment offered. Read more details at http://www.mayoclinic.com/health/abdominal-pain/MY00390/DSECTION=causes.