From f1d0ae5ea14ae8b8f9a6d5b5fc8bbe307ee226e2 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 24 Jul 2014 16:42:30 +0100 Subject: [PATCH] Added separate file for database commands --- Saviour Backup System/databaseTools.cs | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Saviour Backup System/databaseTools.cs diff --git a/Saviour Backup System/databaseTools.cs b/Saviour Backup System/databaseTools.cs new file mode 100644 index 0000000..00e49e1 --- /dev/null +++ b/Saviour Backup System/databaseTools.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Data.SqlServerCe; +using System.IO; +using System.Windows.Forms; + +namespace Saviour_Backup_System +{ + class databaseTools + { + private static string databaseName = "db.sdf"; + public static void initDatabase() + { + try{ + if (!File.Exists(databaseName)) + { + SqlCeEngine SQLEngine = new SqlCeEngine("Data Source = " + databaseName); + SQLEngine.CreateDatabase(); //Creates the database if it doesnt exist already + + SqlCeConnection conn = new SqlCeConnection("Data Source = " + databaseName); + conn.Open(); + SqlCeCommand cmd = conn.CreateCommand(); + + cmd.CommandText = "CREATE TABLE Rules (%%)"; //Fill these in! (Before running) + cmd.ExecuteNonQuery(); + } + } + catch (Exception err) { MessageBox.Show("An Error has occured: \n" + err.ToString()); } + } + public static string queryDatabase(string sqlCode) + { + return ""; + } + + public static void modifyDatabase(string sqlCode) + { + + } + + public static void clearTable(string tableName) + { + modifyDatabase("DELETE FROM " + tableName + ";"); + } + } +}