Well, what is your actual problem? Your description is very general at best, and without knowing any of your code (and
DB libs), and not knowing what goes wrong where and what should happen instead... well I guess you know what I'm trying to say. Be more specific. A LOT!
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)