I have now read a lot about SQL injection and trying to prevent it. I've come across several articles about how and why to use
Command.Parameters.Add()
But I am still looking for an answer how and why it is preventing SQL injection.
MSDN doesn't have very much information about this.
Here is a example how I use it:
SqlCommand myCommand = new SqlCommand("SELECT * FROM table WHERE name = @name ", myConnection);
myCommand.Parameters.Add("@name", SqlDbType.NVarChar, 20).Value = "MaMu2";
Is my code even safe towards SQL injection, or am I wrong?
EDIT: main question is: how does it work internally?