I am creating a stock program and would like the query of items to be filtered by a combobox, ie, when typing in the search field only the results regarding the parameter of the combobox appear.
This is my SQL query code:
DataTable tabela = new DataTable();
SqlDataAdapter da = new SqlDataAdapter("Select " +
"sc.scat_cod, sc.scat_nome, sc.cat_cod, c.cat_nome " +
"from subcategoria sc " +
"inner join categoria c on sc.cat_cod = c.cat_cod " +
"where " +
"(sc.scat_nome like '%" + valor + "%') or (c.cat_nome like '%" + valor + "%')", conexao.StringConexao);
da.Fill(tabela);
return tabela;
With this code when entering in the search field the parameter add and all results are shown, without any filter, can someone help me solve this problem that distresses me?