Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. private void txtBusca_TextChanged(object sender, EventArgs e)
  2. {
  3. if(comboBox1.Text == "Ativo")
  4. {
  5. string strSelect = "SELECT * FROM Produto WHERE Nome LIKE (@Nome)";
  6.  
  7. using (MySqlConnection conn = new MySqlConnection("server=127.0.0.1;database=ProdPacote; Uid=root; pwd=1234;"))
  8. {
  9. MySqlDataAdapter da = new MySqlDataAdapter(strSelect, conn);
  10. //Passagem por parĂ¢metros.
  11. da.SelectCommand.Parameters.AddWithValue("@Nome", txtBusca.Text + "%");
  12. DataSet ds = new DataSet();
  13. da.Fill(ds, "Nome");
  14. dataGridView1.DataSource = ds.Tables["Nome"];
  15. }
  16. }
  17.  
  18. string strSelect = "SELECT * FROM Produto WHERE Nome LIKE (@Nome) AND Activos=true";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement