Play Query Dice For Datagridview in C#

Asked

Viewed 98 times

1

Hello guys I’m facing 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 will only load the products from that list. I created a query, ran it separately and it works, the problem is, how to pass the combobox text as parameter when calling the query?

it should be something like this, but it makes a mistake

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

I managed to pass the parameter, I was doing wrong, the correct was:

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

But it shows no data in datagridview :/

  • Do not put the solution in the body of the question, publish a new answer with the solution.

1 answer

2

I’m sorry I answered 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);

Of calling between "%" didn’t work, I believe it only works for selects with the LIKE. Now it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.