That is weird to have them both fail at the same time. That makes me thing it's a hardware issue.
Are they recognized by the BIOS? e.g. When you boot up your computer, does it list your hard drive(s) and the optical drives (before windows loads)?
1) If not, it could be a problem with the motherboard or it could simply be a bad connection. You said you can open and close the trays, so it's probably not the power supply. The first thing I would do is check the IDE cables. Make sure they are seated properly, unplug them and plug them back in. Double check the master/slave jumpers. If they are on the same IDE cable, the one at the end of the cable should be set to master. The one in the middle of the cable should be set to slave. Double check that both of the IDE channels are enabled in the BIOS.
If none of that works, I would suggest trying to install another optical drive (a spare one or borrow one from somebody), just to see if maybe it's a concidence and both drives are fried..possibly due to a power surge or whatever. If this third drive is still not recognized, then I would guess you have a motherboard issue or ...
...a power supply problem. The power supply is relatively easy to swap out, but you need a spare one, which you probably don't have unless you have a second computer. The power supply could be fried (e.g. power surge or old age) or it may not be powerful enough...this could definitely be the case if you have added new hardware recently. In either case, you won't know until you swap it out for a different one and/or a more powerful one.
2) Now, if the BIOS does recognize the drive, then it's a software/OS problem. Check this first: Settings > Control Panel > System > Hardware > Device Manager. Under DVD/CD-ROM Drives, does it list your drives there? Do either of them have a question mark or an exclamaition point next to them? Try right clicking on each of them and choosing Uninstall. Reboot and it should detect them, reinstall the drivers, etc.