That happened to my Dad. He spent $800 replacing various parts he knew he needed to eventually replace. The check engine light didn't go away. He took it into the shop, they ran the diagnostics, and it turned out to be a blown resistor inside a $35 component.
Later he gave me his car. When the check engine came on, I took it down to the shop. They replaced the battery, ignition switch and vacuum hose. My Dad paid the $900 since these were "pre-existing conditions" that he should have fixed. I think I finally got all the bugs out of this car. Haven't had any major problems since then.