/// <summary> /// Refreshes values in DataGridView /// </summary> private void refreshTable() { try { DBReader.connectionOpen(connection); adapter = new MySqlDataAdapter(); if (textBoxSelectedPlayer.Text == "For all") { adapter.SelectCommand = DBReader.commandForTheWholeTable(connection, entityName); } else if (textBoxSelectedPlayer.Text.StartsWith("Player ")) { playersID = DBReader.selectAllPlayersID(connection, DBName); int ID = playersID[Int32.Parse(textBoxSelectedPlayer.Text.Substring(7)) - 1]; adapter.SelectCommand = DBReader.commandForSelectedPlayer(connection, entityName, ID); } dataSet = new DataTable(); adapter.Fill(dataSet); BindingSource source = new BindingSource(); source.DataSource = dataSet; tableEntity.DataSource = source; adapter.Update(dataSet); } catch (MySqlException ex) { MessageBox.Show(ex.Message); } finally { DBReader.connectionEnd(connection); } }