private void button1_Click(object sender, EventArgs e) { DBConnect baza = new DBConnect("admin", "qwerty"); if (textBox1.Text == null || textBox2.Text == null) { MessageBox.Show("Wpisz dane"); } else { string prac = textBox1.Text.Replace(" ", "_"); baza.Create_User(prac, textBox2.Text); } string MyConString = "SERVER=localhost;" + "DATABASE=baza;" + "UID=root;"; MySqlConnection connection = new MySqlConnection(MyConString); string command = "select User from mysql.user;"; MySqlDataAdapter da = new MySqlDataAdapter(command, connection); DataTable dt = new DataTable(); da.Fill(dt); foreach (DataRow row in dt.Rows) { comboBox1.DataSource = dt; } comboBox1.DisplayMember = "User"; connection.Close(); textBox1.Text = ""; textBox2.Text = ""; }
private void button1_Click(object sender, EventArgs e) { DBConnect baza = new DBConnect("admin", "qwerty"); if (textBox1.Text == null || textBox2.Text == null) MessageBox.Show("Wpisz dane"); else { string prac = textBox1.Text.Replace(" ", "_"); baza.Create_User(prac, textBox2.Text); } string MyConString = "SERVER=localhost;" + "DATABASE=baza;" + "UID=root;"; MySqlConnection connection = new MySqlConnection(MyConString); string command = "select User from mysql.user;"; MySqlDataAdapter da = new MySqlDataAdapter(command, connection); DataTable dt = new DataTable(); da.Fill(dt); foreach (DataRow row in dt.Rows) comboBox1.DataSource = dt; comboBox1.DisplayMember = "User"; connection.Close(); textBox1.Text = ""; textBox2.Text = ""; }