private void button3_Click(object sender, EventArgs e) { //variable gets event string selected = listBox1.GetItemText(listBox1.SelectedItem); //gets total time double total; double[] num = new double[7]; num[0] = Convert.ToDouble(textBox2.Text); num[1] = Convert.ToDouble(textBox3.Text); num[2] = Convert.ToDouble(textBox4.Text); num[3] = Convert.ToDouble(textBox5.Text); num[4] = Convert.ToDouble(textBox6.Text); num[5] = Convert.ToDouble(textBox7.Text); num[6] = Convert.ToDouble(textBox8.Text); total = num[0] + num[1] + num[2] + num[3] + num[4] + num[5] + num[6]; total = total - (num.Min() + num.Max()); total = total / 5; //class created to store athletes info Athlete AthleteScore = new Athlete(); //stores name of athlete AthleteScore.firstName = dataGridView1.SelectedCells[1].Value.ToString(); AthleteScore.lastName = dataGridView1.SelectedCells[2].Value.ToString(); //instance of class used to enter score Scoring TimeEntry = new Scoring(); //member function adds the Time to database TimeEntry.EnterScore(total, selected, AthleteScore.firstName, AthleteScore.lastName); //this will update the score board to reflect the changes string View = "SELECT * FROM " + SelectedEvent + " ORDER BY Score DESC;";//gets team table from database using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con)) { con.Open(); //opens DB if (con.State == ConnectionState.Open) // if connection.Open was successful { //this sends sql commands to database DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(View, con); da.Fill(ds); dataGridView1.DataSource = ds.Tables[0].DefaultView; } else { MessageBox.Show("Connection failed."); } } con.Close(); } }