How does SQLParameter prevent SQL Injection?

后端 未结 4 1384
借酒劲吻你
借酒劲吻你 2020-11-22 07:59

What exactly is going on in the background that makes it so SQLParameter prevents SQL Inection attacks in a .NET Parameterized query? Is it just stripping out any suspect c

4条回答
  •  失恋的感觉
    2020-11-22 08:06

    "Parameter collections such as SqlParameterCollection provide type checking and length validation. If you use a parameters collection, input is treated as a literal value, and SQL Server does not treat it as executable code. An additional benefit of using a parameters collection is that you can enforce type and length checks. Values outside of the range trigger an exception. This is a good example of defense in depth."

    http://msdn.microsoft.com/en-us/library/ff648339.aspx

提交回复
热议问题