.net - infopath query and sql injection problem -
How do I protect my site from SQL injection when I'm getting? Description = value
from url
and searching the object in the XML column in the database with the specified value?
Here is the sample code:
from sqlQuery = string.format (@ [data] "+ schema + @". [MyOBjects] WHERE " Data.exist ('/ data ["value" = \ "{0} \"]') = 1 "+", property, value); Thanks for any help
about the following View the article to protect your code from SQL injection:
In your case, you want to use parameterized queries. Checkout "Step 3. Use Parameters with dynamic SQL".
You can do anything like this:
string connection string = "..."; String schema = "..."; String value = "..."; (SqlConnection connection = New SqlConnection (connectionString)) {string sql = string.format ("Select [data] FROM {0}. [MyOBjects] WHERE data.exist ('/ data [\" theValue \ "= sql: variable ( \ "@value \ @ Value ", System.Data.SqlDbType.NVarChar, 255) {value = value}); ....}
Comments
Post a Comment