These medications have high risk of hypoglycemia (low blood sugars) during prolonged fasting. You could still fast while being on these medications but your physician will help you time the doses of medications. The doses may need to be reduced or replaced by tablets that do not produce hypoglycemia.
Hypoglycemia during fasting is quite dangerous. You should be breaking the fast if you see blood sugar values below 70 mg/dl or see falling blood sugar values on monitoring.