1
How do you do a bank search and show on DataGrid
, only that I select a category
I’m not sure how to do this kind of search in the bank, when I select in the ComboBox1
the active word, it brings me only the active products, however I wanted to make my textBox
search only the name of active products.
let’s assume that I have two products with the same name, but one is active and the other inactive, if I select active it seeks only this name that is active
code I’m using(at least trying to do this):
private void txtBusca_TextChanged(object sender, EventArgs e)
{
if(comboBox1.Text == "Ativo")
{
string strSelect = "SELECT * FROM Produto WHERE Nome LIKE (@Nome)";
using (MySqlConnection conn = new MySqlConnection("server=127.0.0.1;database=ProdPacote; Uid=root; pwd=1234;"))
{
MySqlDataAdapter da = new MySqlDataAdapter(strSelect, conn);
//Passagem por parâmetros.
da.SelectCommand.Parameters.AddWithValue("@Nome", txtBusca.Text + "%");
DataSet ds = new DataSet();
da.Fill(ds, "Nome");
dataGridView1.DataSource = ds.Tables["Nome"];
}
}
But what exactly is the problem? Could you elaborate further on your question?
– João Martins
@Joãomartins edited the question, please see if it is better to understand
– Pietro Nunciaroni