public Form1() { InitializeComponent(); sort = Sort.ID; goal = 100; dbConnection = new SQLiteConnection("Data Source=GradeDatabase.db;Version=3;"); dbConnection.Open(); // Test for grades table try { string sql = "select * from grades"; SQLiteCommand command = new SQLiteCommand(sql, dbConnection); SQLiteDataReader reader = command.ExecuteReader(); } catch { string sql = GradeItem.MakeTableText(); SQLiteCommand command = new SQLiteCommand(sql, dbConnection); command.ExecuteNonQuery(); } label7.Text = ""; RefreshDisplay(); }
private void NewDatabaseClick(object sender, EventArgs e) { if (MessageBox.Show("Would you like to drop all tables and rebuild the database?", "Drop Tables", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (MessageBox.Show("Are you REALLY sure you want to drop all tables and rebuild the database?", "Drop Tables", MessageBoxButtons.YesNo) == DialogResult.Yes) { string sql; SQLiteCommand command; sql = "DROP TABLE IF EXISTS grades"; command = new SQLiteCommand(sql, dbConnection); command.ExecuteNonQuery(); sql = GradeItem.MakeTableText(); richTextBox1.Text = sql; command = new SQLiteCommand(sql, dbConnection); command.ExecuteNonQuery(); MessageBox.Show("done."); } } }