Advertisement
Guest User

Untitled

a guest
Jan 24th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. private void btnRefresh_Click(object sender, EventArgs e)
  2. {
  3. string connection = "server=localhost;database=teste_etb;user=root;password=******";
  4. MySqlConnection con = new MySqlConnection(connection);
  5. con.Open();
  6. MySqlCommand command = new MySqlCommand();
  7. command.Connection = con;
  8. MySqlDataAdapter MyDA = new MySqlDataAdapter();
  9. sqlSelectAll = "SELECT * from conteudos";
  10. MyDA.SelectCommand = new MySqlCommand(sqlSelectAll, con);
  11. DataTable table = new DataTable();
  12. MyDA.Fill(table);
  13. BindingSource bSource = new BindingSource();
  14. bSource.DataSource = table;
  15. dataGridView1.DataSource = bSource;
  16. con.Close();
  17. }
  18.  
  19. private void txtSearch_TextChanged(object sender, EventArgs e)
  20. {
  21.  
  22. DataView dv = new DataView(table);
  23. dv.RowFilter = string.Format("Nome LIKE '%{0}'");
  24. dataGridView1.DataSource = dv;
  25.  
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement