This site offers to retrieve them for a small fee...much less than dealer. Many times, if you did not specify a code, the code is programmed at the selling dealer using the last 4 numbers of the VIN or some other easy to remember series of numbers....you can also check the owners manual to see if a tech wrote it down.
http://www.radio-code.com/
You can buy devices which plug into the cigarette lighter port which prevent memory loss in car computers or radios if you need to disconnect the battery...neat tool to have for future use. Parts stores sell them or you can buy online.
.http://www.amazon.com/CTA-Tools-Computer-Memory-Saver/dp/B000GKD5Q0
http://www.toolsource.com/computer-memory-saver-style-p-71759.html