Queries in my C # Winforms project are being done through StringBuilder
. It was suggested here in the OS that I changed the way to generate the query from Consulta.Append("Select * from...")
to @"select * from..."
because it was redundant. Here's a snippet of code after the change:
string Consulta = @"select nome as Nome,
endereco as Endereço,
telefone as Telefone,
dataCadastro as [Data de Cadastro]
From clientes
where dataCadastro='"+ Convert.toString(dePeriodo.Text) +"'
and status<>0";
foreach (DataRow iRow in Dados.SQLData.dsData(Consulta).Tables[0].Rows)
{
//restante aqui
}
It turns out that by using the method you can not concatenate the parameter of the DateEdit (dePeriodo)
component because the double quotes that are in ...dataCadastro='"+ dePeriodo...
, which opens the concatenation, is actually closing the query . How do I concatenate the value of the component with query without causing this error?