No, you will not be completely safe. As others noted, parameterized queries always go the way โ no matter how you access the database.
This is a small urban legend in which you will feel safe. I think the reason that people are under this fallacy is because most people assume that you will call procs with parameterized queries from your code. But if you do not, if, for example, you do something like below, you are wide open:
SqlCommand cmd = new SqlCommand("exec @myProc " + paramValue, con); cmd.ExecuteNonQuery();
Because you are using unfiltered content from the end user. Again, all they need to do is stop the line (";"), add their dangerous teams, and boom - you hit.
(Aside, if you are on the Internet, do not accept unfiltered garbage from the browser query string, which makes it absurdly easy to do very bad things for your data.)
If you parameterize queries, you are in better shape. However, as others have mentioned, if your proc still creates dynamic SQL and its execution, problems can still occur.
I should note that I am not an antiprock. Procs can be very helpful in resolving certain data access issues. But procs is not a "silver bullet solution for SQL injection."
John Rudy Oct 27 '08 at 13:57 2008-10-27 13:57
source share