I have a function that adds a filter to SqlDataSource
. This expression contains LIKE
in the query. However, if the person places a character as '
, an error occurs (evidenced by SQL Injection).
string cliente = TB_Cliente.Text;
string retorno = "CodOrdemServico = CodOrdemServico ";
if (cliente.Length > 0)
{
retorno += String.Format("AND Cliente LIKE '%{0}%'", cliente);
}
DS_Grid.FilterExpression = retorno;
How can I escape the LIKE
above?