Avoiding SQL Injection in SQL query with Like Operator using parameters?

Posted by MikeJ on Stack Overflow See other posts from Stack Overflow or by MikeJ
Published on 2008-10-23T03:46:20Z Indexed on 2010/03/27 8:43 UTC
Read the original article Hit count: 226

Filed under:
|
|
|
|

Taking over some code from my predecessor and I found a query that uses the Like operator:

SELECT * FROM suppliers WHERE supplier_name like '%'+name+%';

Trying to avoid SQL Injection problem and parameterize this but I am not quite sure how this would be accomplished. Any suggestions ?

note, I need a solution for classic ADO.NET - I don't really have the go-ahead to switch this code over to something like LINQ.

© Stack Overflow or respective owner

Related posts about ADO.NET

Related posts about sql-injection