//Update statement public void Update(string id) { Form2 form = new Form2(); List <bool> list = new List <bool>(form.getList()); string set = ""; for (int i = 0; i < 56; i++) { int index = i + 1; set += "seat_" + index + "='" + Convert.ToInt16(list[i]) + "', "; } set += "seat_" + 56 + "='" + Convert.ToInt16(list[55]) + " "; string query = "UPDATE race SET " + set + "' WHERE id='" + id + "'"; //Open connection if (this.OpenConnection() == true) { //create mysql command MySqlCommand cmd = new MySqlCommand(); //Assign the query using CommandText cmd.CommandText = query; //Assign the connection using Connection cmd.Connection = connection; //Execute query cmd.ExecuteNonQuery(); //close connection this.CloseConnection(); } }