Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using MySql.Data.MySqlClient;
- namespace taxi_mysql
- {
- public partial class disp : Form
- {
- public disp()
- {
- InitializeComponent();
- }
- MySqlConnection connect = new MySqlConnection("datasource=localhost;port=3306;Initial Catalog='testmenu';username=root;password=");
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- string selectQuery = "SELECT * FROM testmenu.foods";
- MySqlCommand commad = new MySqlCommand(selectQuery, connect);
- MySqlDataReader read1;
- try
- {
- connect.Open();
- read1 = commad.ExecuteReader();
- while (read1.Read())
- {
- string fdtype = read1.GetString("food");
- comboBox1.Items.Add(fdtype);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
Add Comment
Please, Sign In to add comment