What would be the best way to stop SQL injection with a LIKE
statement? So here is a example of the code:
string search = Server.HTMLDecode(userEnteredSearchText);
SqlCommand comm = new SqlCommand("SELECT Result WHERE (Keyword LIKE '%" + @search + "%') "
comm.Parameters.Add(new SqlParameter("search", search));
This is what I have been doing other sql statements and it seems like special characters such as '
and %
can't break those statements, but I'm guessing with a LIKE
statement you need to do a escape key or something?