Have you ever lost your hard-on while having sex? If yes how did you deal with it and what would you suggest for someone who suffers from this problem?
Of course. Here, I just addressed something similar the other day, but in doing so, talked about losing wood.
Basically, shit happens, but if you make her cumming the focus, and add a lot of foreplay, and you are not fucking some evil cunt who gets mad after you made her cum half a dozen times because your dick is not cooperating, then you should be fine and hopefully get out of your own head, which could be part of the problem. Do you get morning wood? That is usually a good sign that the mechanics are OK. If you not getting hard persists and is all the time, then I suggest talking to your Physician.