I always try to keep secure coding practices in mind. I will use Stored procedures, input validation and sanitation and always re-authenticate on page load if I am utilizing session, application, or cookies. I do this all coming from a web-hacker/ security upbringing so I am a bit more conciseness and knowledgeable about these issues than most. I am a purely self taught IT professional and I have a firm grasp on how exploits are executed, what makes them work, and how to code in a manner that doesn't allow them. I however am only one man at one business, most programmers coming out of college I fear are not being taught the security aspect of it as much as they should be.
Even with a solid background in security it is not easy to audit my code 100% on every project. Programming is a complex and time consuming profession. Security auditing is hard to fit in between 10s of thousands of lines of code and reporting to department heads concerning there projects. With the amount of code I write we could probably hire a part time security auditor to do nothing but read code all day and document potential security issues. This however is not feasible or in the budgets. Also it would add cost and reduce the benefit to dev-ing in house as opposed to outsourcing.
This is, always has been, and probably always will be a difficult issue to address. I think the only way to really make sure the number of exploits out there drop is to increase the teaching of secure programming in schools and universities. Being able to code secure is only half of it. Having the knowledge of how these exploits work will help any programmer to consciously avoid coding in a way to allow these.