The ED may not be related to diabetes at all. Speak to a physician. It's your best bet.
Hi,
The best way is to have excellent blood sugar control. This means normal levels of fasting 70 - 95, and post eating not more than 140. If you do this the ED should be recoverable.
To control BS if it is high look into low carb diet, daily exercise, and normalizing weight. YOu may also discuss your medications with your dr.
If you blood sugar is good, consider seeing a urologist to investigate other possible causes of the ED.
Controlling your Blood Sugars (BG) so they are in the normal range could help with ED.