Don't write very much code! Well, not all at once anyway. Develop incrementally. Write a little, compile, test (if appropriate), repeat until done. By writing a small amount of code at a time you know any compiler errors you encounter were introduced recently - if you didn't write very much you'll have a better idea where to focus your attention.
ALWAYS ALWAYS ALWAYS fix the first compiler error first (by this I mean the one the compiler spit out first). The first error is almost always a real error. Subsequent errors can simply be the result of the compiler being confused by the first error. It makes an attempt to tell you everything that is wrong but it is not very good at it. As you become more experienced with compiler errors you can dive down the list, ignoring the appropriate ones, and fixing the valid ones. Until then, and especially when you feel dazed, confused, angry, frustrated (fill in your favorite compiler-error emotion here), et cetera, you should fix the first error first, if the second error makes little or no sense, just compile and fix the new first compiler error, if any, repeat until done.
If you can't figure the error out, try commenting out the code you have most recently written until it goes away. Then, reintroduce the commented out code, a bit at a time, until the error reappears. Make sure you understand what specific code caused the error and commit it to memory so that you can avoid that error in the future. This is called learning from experience - very important to a programmer's sanity and success! Maybe everyone's sanity and success for that matter.
Take regular breaks. Especially when you are feeling stuck and frustrated. You'll be amazed how much more fun programming can be if you approach it as an interesting challenge when you are feeling fresh. I, and many others I know, have solved many-a-problem by simple moving away from the computer. Some unconscious part of your mind continues to puzzle over the problem and often solves it for you with little or no apparent effort at all.