Guest User

Untitled

a guest
Oct 17th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using MySql.Data.MySqlClient;
  2.  
  3. namespace taxi_mysql
  4. {
  5. public partial class disp : Form
  6. {
  7.  
  8.  
  9. public disp()
  10. {
  11. InitializeComponent();
  12. }
  13.  
  14. MySqlConnection connect = new MySqlConnection("datasource=localhost;port=3306;Initial Catalog='testmenu';username=root;password=");
  15.  
  16. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  17. {
  18. string selectQuery = "SELECT * FROM testmenu.foods";
  19. MySqlCommand commad = new MySqlCommand(selectQuery, connect);
  20.  
  21.  
  22. MySqlDataReader read1;
  23. try
  24. {
  25. connect.Open();
  26. read1 = commad.ExecuteReader();
  27.  
  28. while (read1.Read())
  29. {
  30. string fdtype = read1.GetString("food");
  31. comboBox1.Items.Add(fdtype);
  32. }
  33. }
  34. catch (Exception ex)
  35. {
  36. MessageBox.Show(ex.Message);
  37. }
  38. }
Add Comment
Please, Sign In to add comment