public Form1() { InitializeComponent(); config.DBConnection dBConnection = config.DBConnection.Instance(); dBConnection.Username = "******"; dBConnection.Password = ""; dBConnection.DatabaseName = "rechnung"; FillListBox(); }
private void FillListBox() { config.DBConnection dBConnection = config.DBConnection.Instance(); if (dBConnection.IsConnect()) { string query = "SELECT rechnung.ID FROM rechnung;"; try { var cmd = new MySqlCommand(query, dBConnection.Connection); var reader = cmd.ExecuteReader(); while (reader.Read()) { this.listBox1.Items.Add(reader.GetInt32(0)); } dBConnection.Close(); } catch (Exception e) { } } }