Playing Query Data For DataGridView in C #

1

Hello everyone, I'm having problems with a listing.

I have a DataGridView loading a list of products automatically and a combobox with the names of the categories, the idea is that when selecting a category and clicking the list button, DataGridView loads only the products from that list. I created a query, I ran separately and it works, the problem is, how do I pass the text of the combobox as a parameter at the time of calling the query?

should be something like this, but it gives error

private void btListar_Click(object sender, EventArgs e)
{
    string sCategoria = cbCategoriaProduto.Text;
    this.tabelaEstoqueTableAdapter.FillByCategoria(
          this.baseDadosInfoMasterDataSet.TabelaEstoque, sCategoria);
}

I was able to pass the parameter, I was doing wrong, the correct one was:

this.tabelaEstoqueTableAdapter.FillByCategoria(
     this.baseDadosInfoMasterDataSet.TabelaEstoque,
     "%" + cbCategoriaProduto.Text + "%");

But it does not show any data in the datagridview: /

    
asked by anonymous 03.04.2015 / 19:12

1 answer

2

Sorry for answering the same question.

I solved my problem now, after a few hours trying.

The right way to call my query was:

this.tabelaEstoqueTableAdapter.FillByCategoria(
     this.baseDadosInfoMasterDataSet.TabelaEstoque,
     cbCategoriaProduto.Text);

Calling between "%" was not working, I think it only works for selects with LIKE . Now it worked.

    
03.04.2015 / 20:15