0
I am creating a stock program and I would like the item query to be filtered by a combobox, that is, when writing in the search field only the results related to the combobox parameter 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 typing in the search field the parameter some and all the results are shown, without any filter, someone can help me to solve this problem that afflicts me?
you need to qualify the filter and work with its conditions... present the rest of the method if you have no help
– Leandro Angelo
Post details of the context, because the statement is very vague. For example: several subcategories of a single category OR several pairs category+subcategory can be marked on the combobox?
– José Diz