private void button1_Click(object sender, EventArgs e) { //string used to place cell contents into string country; //gets selected row int rowindex = dataGridView2.CurrentCell.RowIndex; //enters selected row into a string variable country = dataGridView2.CurrentCell.Value.ToString(); //string to store selected gender string selected = listBox1.GetItemText(listBox1.SelectedItem); //object used to store athletes info Athlete AddAthlete = new Athlete(); //add athletes info to object AddAthlete.firstName = textBox1.Text; AddAthlete.lastName = textBox2.Text; AddAthlete.gender = selected; //object from registration class Registration RegAthlete = new Registration(); //calls member function of Registration RegAthlete.registerAthlete(AddAthlete.firstName, AddAthlete.lastName, AddAthlete.gender, country); //this will refresh the list string ViewTable = "SELECT * FROM 'Athlete Information'";//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(ViewTable, con); da.Fill(ds); dataGridView1.DataSource = ds.Tables[0].DefaultView; } else { MessageBox.Show("Connection failed."); } } con.Close(); } }
private void button3_Click(object sender, EventArgs e) { 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(); //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry from event to the specific event string sql = String.Format("UPDATE " + SelectedEvent + " SET Score = " + total + " WHERE \"Athlete First Name\" = '" + AthleteScore.firstName + "' AND \"Athlete Last Name\" = '" + AthleteScore.lastName + "';"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } } MessageBox.Show("Score has been entered into " + AthleteScore.firstName + " " + AthleteScore.lastName + "'s score"); //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(); } }
private void button1_Click(object sender, EventArgs e) { //string used to place cell contents into string country; //gets selected row int rowindex = dataGridView2.CurrentCell.RowIndex; //enters selected row into a string variable country = dataGridView2.CurrentCell.Value.ToString(); //string to store selected gender string selected = listBox1.GetItemText(listBox1.SelectedItem); //object used to store athletes info Athlete AddAthlete = new Athlete(); //add athletes info to object AddAthlete.firstName = textBox1.Text; AddAthlete.lastName = textBox2.Text; AddAthlete.gender = selected; //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO 'Athlete Information' ('TeamName' , 'AthleteFirstName', 'AthleteLastName', 'Gender') " + "VALUES ('" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + selected + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } MessageBox.Show("Entry has been entered into Database!"); con.Close(); } string ViewTable = "SELECT * FROM 'Athlete Information'";//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(ViewTable, con); da.Fill(ds); dataGridView1.DataSource = ds.Tables[0].DefaultView; } else { MessageBox.Show("Connection failed."); } } con.Close(); } }
private void button1_Click(object sender, EventArgs e) { //class created to store athletes info Athlete AddAthlete = new Athlete(); //objects used to store the athletes info AddAthlete.firstName = dataGridView1.SelectedCells[1].Value.ToString(); AddAthlete.lastName = dataGridView1.SelectedCells[2].Value.ToString(); //stores country name string country = dataGridView1.SelectedCells[0].Value.ToString(); //select puts the selected event into a string string selected = listBox1.GetItemText(listBox1.SelectedItem); if (selected == "Mens 500m Speed Skating, Monday, 12:00pm, Rink 1") { //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO Events ('Event Name', 'Team Name', 'Athlete First Name'," + "'Athlete Last Name', 'Event_Time', 'Event Day', 'Rink') VALUES('Mens 500m Speed Skating', '" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '12:00pm', 'Monday', 'Rink 1');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } con.Close(); MessageBox.Show("Athlete has been entered into Event!"); //creates variable for connection string using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn)) { conn.Open(); //opens DB //checks connection and fills grid view with Race table if (conn.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO \"ss500m Times Men\" ('Athlete First Name', 'Athlete Last Name', " + "'Team Name') VALUES('" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + country + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); conn.Close(); } else { MessageBox.Show("Connection failed."); } } } } } if (selected == "Womens 500m Speed Skating, Monday, 12:00pm Rink 2") { //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO Events ('Event Name', 'Team Name', 'Athlete First Name'," + "'Athlete Last Name', 'Event_Time', 'Event Day', 'Rink') VALUES('Womens 500m Speed Skating', '" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '12:00pm', 'Monday', 'Rink 2');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } MessageBox.Show("Athlete has been entered into Event!"); con.Close(); } //creates variable for connection string using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn)) { conn.Open(); //opens DB //checks connection and fills grid view with Race table if (conn.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO \"ss500m Times Women\" ('Athlete First Name', 'Athlete Last Name', " + "'Team Name') VALUES('" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + country + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); conn.Close(); } else { MessageBox.Show("Connection failed."); } } } } if (selected == "Mens 1000m Speed Skating, Tueday, 12:00pm, Rink 1") { //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO Events ('Event Name', 'Team Name', 'Athlete First Name'," + "'Athlete Last Name', 'Event_Time', 'Event Day', 'Rink') VALUES('Mens 1000m Speed Skating', '" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '12:00pm', 'Tuesday', 'Rink 1');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } MessageBox.Show("Athlete has been entered into Event!"); con.Close(); } //creates variable for connection string using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn)) { conn.Open(); //opens DB //checks connection and fills grid view with Race table if (conn.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO \"ss1000m Times Men\" ('Athlete First Name', 'Athlete Last Name', " + "'Team Name') VALUES('" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + country + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); conn.Close(); } else { MessageBox.Show("Connection failed."); } } } } if (selected == "Womens 1000m Speed Skating, Tuesday, 12:00pm, Rink 2") { //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO Events ('Event Name', 'Team Name', 'Athlete First Name'," + "'Athlete Last Name', 'Event_Time', 'Event Day', 'Rink') VALUES('Womens 1000m Speed Skating', '" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '12:00pm', 'Tuesday', 'Rink 2');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } MessageBox.Show("Athlete has been entered into Event!"); con.Close(); } //creates variable for connection string using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn)) { conn.Open(); //opens DB //checks connection and fills grid view with Race table if (conn.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO \"ss1000m Times Women\" ('Athlete First Name', 'Athlete Last Name', " + "'Team Name') VALUES('" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + country + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); conn.Close(); } else { MessageBox.Show("Connection failed."); } } } } if (selected == "Mens 1500m Speed Skating, Wednesday, 12:00pm, Rink 1") { //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO Events ('Event Name', 'Team Name', 'Athlete First Name'," + "'Athlete Last Name', 'Event_Time', 'Event Day', 'Rink') VALUES('Mens 1500m Speed Skating', '" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '12:00pm', 'Wednesday', 'Rink 1');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } MessageBox.Show("Athlete has been entered into Event!"); con.Close(); } //creates variable for connection string using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn)) { conn.Open(); //opens DB //checks connection and fills grid view with Race table if (conn.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO \"ss1500m Times Men\" ('Athlete First Name', 'Athlete Last Name', " + "'Team Name') VALUES('" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + country + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); conn.Close(); } else { MessageBox.Show("Connection failed."); } } } } if (selected == "Womens 1500m Speed Skating, Wednesday, 12:00pm, Rink 2") { //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO Events ('Event Name', 'Team Name', 'Athlete First Name'," + "'Athlete Last Name', 'Event_Time', 'Event Day', 'Rink') VALUES('Womens 1500m Speed Skating', '" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '12:00pm', 'Wednesday', 'Rink 2');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } MessageBox.Show("Athlete has been entered into Event!"); con.Close(); } //creates variable for connection string using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn)) { conn.Open(); //opens DB //checks connection and fills grid view with Race table if (conn.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO \"ss1500m Times Women\" ('Athlete First Name', 'Athlete Last Name', " + "'Team Name') VALUES('" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + country + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); conn.Close(); } else { MessageBox.Show("Connection failed."); } } } } if (selected == "Single Skating Mens, Monday, 11:00am, Rink 3") { //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO Events ('Event Name', 'Team Name', 'Athlete First Name'," + "'Athlete Last Name', 'Event_Time', 'Event Day', 'Rink') VALUES('Single Skating Mens', '" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '11:00am', 'Monday', 'Rink 3');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } MessageBox.Show("Athlete has been entered into Event!"); con.Close(); } //creates variable for connection string using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn)) { conn.Open(); //opens DB //checks connection and fills grid view with Race table if (conn.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO \"Single Skating Men Scores\" ('Athlete First Name', 'Athlete Last Name', " + "'Team Name') VALUES('" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + country + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); conn.Close(); } else { MessageBox.Show("Connection failed."); } } } } if (selected == "Single Skating Womens, Monday, 11:00am, Rink 4") { //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO Events ('Event Name', 'Team Name', 'Athlete First Name'," + "'Athlete Last Name', 'Event_Time', 'Event Day', 'Rink') VALUES('Single Skating Womens', '" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '11:00am', 'Monday', 'Rink 4');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } MessageBox.Show("Athlete has been entered into Event!"); con.Close(); } //creates variable for connection string using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn)) { conn.Open(); //opens DB //checks connection and fills grid view with Race table if (conn.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO \"Single Skating Womens Scores\" ('Athlete First Name', 'Athlete Last Name', " + "'Team Name') VALUES('" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + country + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); conn.Close(); } else { MessageBox.Show("Connection failed."); } } } } if (selected == "Ice Dance Mens, Tuesday, 2:00pm, Rink 3") { //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO Events ('Event Name', 'Team Name', 'Athlete First Name'," + "'Athlete Last Name', 'Event_Time', 'Event Day', 'Rink') VALUES('Ice Dance Mens', '" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '2:00pm', 'Tuesday', 'Rink 3');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } MessageBox.Show("Athlete has been entered into Event!"); con.Close(); } //creates variable for connection string using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn)) { conn.Open(); //opens DB //checks connection and fills grid view with Race table if (conn.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO \"Ice Dance Mens Scores\" ('Athlete First Name', 'Athlete Last Name', " + "'Team Name') VALUES('" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + country + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); conn.Close(); } else { MessageBox.Show("Connection failed."); } } } } if (selected == "Ice Dance Womens, Tuesday, 2:00pm, Rink 4") { //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO Events ('Event Name', 'Team Name', 'Athlete First Name'," + "'Athlete Last Name', 'Event_Time', 'Event Day', 'Rink') VALUES('Ice Dance Womens', '" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '2:00pm', 'Tuesday', 'Rink 4');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } MessageBox.Show("Athlete has been entered into Event!"); con.Close(); } //creates variable for connection string using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn)) { conn.Open(); //opens DB //checks connection and fills grid view with Race table if (conn.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO \"Ice Dance Womens Scores\" ('Athlete First Name', 'Athlete Last Name', " + "'TeamName') VALUES('" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + country + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); conn.Close(); } else { MessageBox.Show("Connection failed."); } } } } if (selected == "Couple Skating, Monday, 5:00pm, Rink 3") { //creates variable for connection string 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 //checks connection and fills grid view with Race table if (con.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO Events ('Event Name', 'Team Name', 'Athlete First Name'," + "'Athlete Last Name', 'Event_Time', 'Event Day', 'Rink') VALUES('Couple Skating', '" + country + "', '" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '5:00pm', 'Tuesday', 'Rink 3');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, con); da.Fill(ds); } else { MessageBox.Show("Connection failed."); } } MessageBox.Show("Athlete has been entered into Event!"); con.Close(); } //creates variable for connection string using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection("data source=OlympiaDB.sqlite")) { using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(conn)) { conn.Open(); //opens DB //checks connection and fills grid view with Race table if (conn.State == ConnectionState.Open) { //adds entry to athlete information string sql = String.Format("INSERT INTO \"Pair Skating Scores\" ('Athlete First Name', 'Athlete Last Name', " + "'Team Name') VALUES('" + AddAthlete.firstName + "', '" + AddAthlete.lastName + "', '" + country + "');"); DataSet ds = new DataSet(); var da = new SQLiteDataAdapter(sql, conn); da.Fill(ds); conn.Close(); } else { MessageBox.Show("Connection failed."); } } } } //this will repopulate Event with the added entry string View = "SELECT * FROM 'Events'"; //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); dataGridView2.DataSource = ds.Tables[0].DefaultView; } else { MessageBox.Show("Connection failed."); } } con.Close(); } }