In my searches, I saw the use of parameterized strings in SQL queries generated as follows:
SqlCommand comm = new SqlCommand(); comm.CommandText="SELECT * FROM table WHERE field LIKE '%' +@var +'%'"; comm.Parameters.AddWithValue("var","variabletext"); SqlDataReader reader = comm.ExecuteReader();
However, it was mentioned in this forum that it falls under SQL injection, despite the fact that it is used in a parameterized string. I can only assume that concatenated strings circumvent all parameterized security and simply insert the value directly as a string. If so, then how to use wildcard operators in a parameterized query, avoiding pasting SQL code?
source share