I have the following query in ASP.NET/C# code which is failing to return any values using a parameter...
select * from MyTable where MyTable.name LIKE @search
>
On the SQL side, this is correct:
select * from MyTable where MyTable.name LIKE '%' + @search + '%'
If the parameter was passed in from outside, it would not matter if it contained single quotes.
On the API side, this should be correct:
myCmd.Parameters.AddWithValue("@search", "%" + search + "%");
The AddWithValue() method does all the necessary escaping for you, no need to interfere.