private void Dismiss_Load(object sender, EventArgs e) { pictureBox1.Image = imageList1.Images[0]; timer1.Enabled = true; label4.Enabled = false; timer1.Interval = 1000; label4.Text = DateTime.Now.ToLocalTime().ToString(); try { mysql Mysql = new mysql(); MySqlConnection conn = Mysql.Connection(); string sql = @"select * from staff"; MySqlDataReader dr = Mysql.GetRead(sql); while (dr.Read()) { comboBox1.Items.Add(dr["name"].ToString()); } dr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { } }
private void button1_Click(object sender, EventArgs e) { try { mysql Mysql = new mysql(); MySqlConnection conn = Mysql.Connection(); string sql = @"select * from staff"; DataSet ds = Mysql.GetDataSet(sql); dataGridView1.DataSource = ds.Tables[0]; } catch (Exception ex) { MessageBox.Show("异常为:" + ex.Message); } finally { } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string Name = comboBox1.SelectedItem.ToString(); try { mysql Mysql = new mysql(); MySqlConnection conn = Mysql.Connection(); string sql = @"select * from staff where name='" + Name + "'"; DataSet ds = Mysql.GetDataSet(sql); dataGridView1.DataSource = ds.Tables[0]; } catch (Exception ex) { MessageBox.Show("异常为:" + ex.Message); } finally { } }