WD-40 does prevent rust, but it's too thin and runny to use in a frame. You can use Boeshield, which is a little thicker, but the best is J.P. Weigles Frame Saver. It's a goey, oily, resin made just for bike frames. It cost around $10 per can and you can treat several frames with one can. I just retreated my frame this morning with J.P..
Check out this link on frame care....
http://www.serotta.com/pages/framecare.html