Psychotherapy, marital counseling, or sex therapy may be helpful in treating cases of impotence that have psychological or emotional causes. A range of other treatments exists for cases of impotence that arise from purely physiological causes. These treatments include vacuum devices, penile injections, and penile implants. These mechanical or physically invasive approaches have largely been superseded, however, by the drug sildenafil citrate (trade name Viagra), which is taken in pill form. This drug works by enhancing the effects of nitric oxide, a chemical that, upon sexual stimulation, is normally released to widen the blood vessels supplying the penis. The increased flow of blood through those vessels into certain tissues in the penis causes an erection. See also sexual dysfunction.
The bad news: Men with diabetes are three times more likely to report having problems with sex than non-diabetic men. The most common sexual problem is Erectile Dysfunction, or ED, sometimes called impotence. Even worse, because ED is such a private issue, many men feel embarrassed to discuss the problem with their doctor, or even their partner, so the problem is never addressed.
The primary nerve fibers to the penis are from the dorsal nerve of the penis, a branch of the pudendal nerve. The cavernosal nerves are a part of the autonomic nervous system and incorporate both sympathetic and parasympathetic fibers. They travel posterolaterally along the prostate and enter the corpora cavernosa and corpus spongiosum to regulate blood flow during erection and detumescence. The dorsal somatic nerves are also branches of the pudendal nerves. They are primarily responsible for penile sensation. 
Additionally, the physiologic processes involving erections begin at the genetic level. Certain genes become activated at critical times to produce proteins vital to sustaining this pathway. Some researchers have focused on identifying particular genes that place men at risk for ED. At present, these studies are limited to animal models, and little success has been reported to date.  Nevertheless, this research has given rise to many new treatment targets and a better understanding of the entire process.
Inside the cell, NOS catalyzes the oxidation of L-arginine to NO and L-citrulline. Endogenous blockers of this pathway have been identified. The gaseous NO that is produced acts as a neurotransmitter or paracrine messenger. Its biologic half-life is only 5 seconds. NO may act within the cell or diffuse and interact with nearby target cells. In the corpora cavernosa, NO activates guanylate cyclase, which in turn increases cyclic guanosine monophosphate (cGMP). Relaxation of vascular smooth muscles by cGMP leads to vasodilation and increased blood flow.
The Massachusetts Male Aging Study (MMAS) documented an inverse correlation between ED risk and high-density lipoprotein (HDL) cholesterol levels but did not identify any effect from elevated total cholesterol levels.  Another study involving male subjects aged 45-54 years found a correlation with abnormal HDL cholesterol levels but also found a correlation with elevated total cholesterol levels. The MMAS included a preponderance of older men.
Penile erection is managed by two mechanisms: the reflex erection, which is achieved by directly touching the penile shaft, and the psychogenic erection, which is achieved by erotic or emotional stimuli. The former uses the peripheral nerves and the lower parts of the spinal cord, whereas the latter uses the limbic system of the brain. In both cases, an intact neural system is required for a successful and complete erection. Stimulation of the penile shaft by the nervous system leads to the secretion of nitric oxide (NO), which causes the relaxation of smooth muscles of corpora cavernosa (the main erectile tissue of penis), and subsequently penile erection. Additionally, adequate levels of testosterone (produced by the testes) and an intact pituitary gland are required for the development of a healthy erectile system. As can be understood from the mechanisms of a normal erection, impotence may develop due to hormonal deficiency, disorders of the neural system, lack of adequate penile blood supply or psychological problems. Spinal cord injury causes sexual dysfunction including ED. Restriction of blood flow can arise from impaired endothelial function due to the usual causes associated with coronary artery disease, but can also be caused by prolonged exposure to bright light.
Commercials for drugs to improve “low T,” or testosterone, the male hormone, are now vying for airtime, but they address desire, not performance. "Male hormone is not an approved treatment for erectile dysfunction," notes Bennett. "It may be used to increase desire in men who have low testosterone, but it doesn’t improve blood flow to an erection." A doctor can do a blood test to check you for low testosterone, but it is a rare cause of ED. Hormone therapy with injections, patches, or gels applied to the skin may improve mood and sex drive, but it likely won’t fix any mechanical issues. Also, testosterone drugs should not be used by men with prostate cancer. Side effects include acne, breast enlargement, prostate enlargement, and fluid retention.
On the horizon is gene therapy that would deliver genes that produce products or proteins that may not be functioning properly in the penile tissue of men with ED. Replacement of these proteins may result in improvement in erectile function. Experimental animal models have demonstrated improvement in erectile function with gene therapy. Human studies may also demonstrate success with this therapy. Gene therapy may take a long time for regulatory approval and public acceptance.
Psychological factors — Psychological issues such as depression, anxiety, guilt or fear can sometimes cause sexual problems. At one time, these factors were thought to be the major cause of impotence. Doctors now know that physical factors cause impotence in most men with the problem. However, embarrassment or "performance anxiety" can make a physical problem worse.
Following a detailed discussion about the history of erectile dysfunction and its risk factors, your doctor will examine the testicles and penis to help determine the cause of erectile dysfunction. Your doctor will check reflexes and pulses in the area to see if problems with blood vessels or nerves are contributing to the erectile dysfunction. If necessary, your doctor will order tests to help diagnose erectile dysfunction.
For many men, stopping smoking is an erectile dysfunction remedy, particularly when ED is the result of vascular disease, which occurs when blood supply to the penis becomes restricted because of blockage or narrowing of the arteries. Smoking and even smokeless tobacco can also cause the narrowing of important blood vessels and have the same negative impact.
There are risks to prosthetic surgery and patients are counselled before the procedure. If there is a post-operative infection, the implant will likely be removed. The devices are reliable, but in the case of mechanical malfunction, the device or a part of the device will need to be replaced surgically. If a penile prosthesis is removed, other non-surgical treatments may no longer work.