Bom estou tentanto fazer uma consulta e quando passo o parâmetro ele parece não ser preenchido, mas quando eu passo o valor diretamente no sql ele funciona.
vejam que estou passando o valor direto no sql:
cmd.CommandText = "SELECT " + Attr + " FROM " + InstituicaoFinanceira.NAME_TABLE
+ " WHERE Nome LIKE CONCAT('%', '" + text + "', '%')";`
Aqui está como devia fica
public Collection<InstituicaoFinanceira> Find(string text)
{
Collection<InstituicaoFinanceira> collection = new Collection<InstituicaoFinanceira>();
using (SqlCommand cmd = this.connSqlServer.Find().CreateCommand())
{
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT " + Attr + " FROM " + InstituicaoFinanceira.NAME_TABLE
+ " WHERE Nome LIKE CONCAT('%', '@Nome', '%')";
cmd.Parameters.Add("@Nome", SqlDbType.VarChar).Value = text;
using (SqlDataAdapter adapter = new SqlDataAdapter(cmd))
{
DataTable tabela = new DataTable();
adapter.Fill(tabela);
foreach (DataRow d in tabela.Rows)
{
collection.Add(this.PreencherObj(d));
}
}
}
return collection;
}