private void button1_Click(object sender, EventArgs e) { var dt = ConecctionDB.ExecuteQuery("SELECT pl.name, sc.score " + "FROM PLAYER pl, SCOREBOARD sc " + "WHERE pl.idscore = sc.idscore order by sc.score desc " + "LIMIT 10"); dataGridView1.DataSource = dt; }
private void button1_Click(object sender, EventArgs e) { var name = txtName.Text; if (name.Length == 0) { MessageBox.Show("you did not enter the name!", "Name Empty", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { //verificacion con la base de datos por si esta repetido var dt = ConecctionDB.ExecuteQuery("SELECT Name " + "FROM PLAYER"); foreach (DataRow dr in dt.Rows) { if (dr[0].ToString().Equals(txtName.Text)) { MessageBox.Show("The name already exist", "name repeated", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Continue = false; break; } } //luego se inicia el juego if (Continue == true) { ConecctionDB.ExecuteNonQuery("INSERT INTO PLAYER(Name) " + $"VALUES('{txtName.Text}')"); Game game = new Game(); game.Show(); this.Close(); } } }