From 0733463b36629698ab25c909f78205cff6a1e7b4 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 9 Nov 2014 18:18:09 +0000 Subject: [PATCH] removed code for making database, premade one used instead. --- Saviour Backup System/databaseTools.cs | 61 ++++---------------------- 1 file changed, 9 insertions(+), 52 deletions(-) diff --git a/Saviour Backup System/databaseTools.cs b/Saviour Backup System/databaseTools.cs index e137d40..9e0286d 100644 --- a/Saviour Backup System/databaseTools.cs +++ b/Saviour Backup System/databaseTools.cs @@ -6,69 +6,26 @@ using System.Threading.Tasks; using System.Data.SqlServerCe; using System.Data; using System.IO; - +using Saviour_Backup_System.Properties; namespace Saviour_Backup_System { class databaseTools { - internal static string databaseName = "db.sdf"; - private static SqlCeConnection conn = new SqlCeConnection("Data Source = " + databaseName); + internal static string databaseName = "saviour.sdf"; + private static SqlCeConnection conn = new SqlCeConnection("Data Source = " + databaseName + "; password=12a712d7e6f71ed07822c219318da2c0"); //password is a hash private static SqlCeCommand cmd = conn.CreateCommand(); - internal static void init(){ - SqlCeEngine SQLEngine = new SqlCeEngine("Data Source = " + databaseName); - SQLEngine.CreateDatabase(); //Creates the database if it doesnt exist already - SQLEngine.Dispose(); - - createTables(); - fillProperties(); - } - private static void fillProperties() { - conn.Open(); - - cmd.CommandText = "INSERT INTO Properties VALUES (?,?);"; - cmd.Parameters.Add(new SqlCeParameter("PROPERTY", SqlDbType.NText)); - cmd.Parameters.Add(new SqlCeParameter("VALUE", SqlDbType.NText)); - - cmd.Parameters["PROPERTY"].Value = "Startup"; - cmd.Parameters["VALUE"].Value = "FALSE"; - cmd.ExecuteNonQuery(); - cmd.Parameters["PROPERTY"].Value = "Save_Location"; - string saveLocation; - switch (OSInfo.Name) - { - case("Windows XP"): - saveLocation = @"C:\Documents and Settings\" + setup.username + @"\Saviour Backup System\My Backups\"; - break; - case("Windows Vista"): - saveLocation = @"C:\Users\" + setup.username + @"\Saviour Backup System\My Backups\"; - break; - default: - saveLocation = @"C:\"; - break; - } - cmd.Parameters["VALUE"].Value = saveLocation; - cmd.ExecuteNonQuery(); - - cmd.Parameters["PROPERTY"].Value = "Window_Style"; - cmd.Parameters["VALUE"].Value = "Office2010Black"; - cmd.ExecuteNonQuery(); - - conn.Close(); - } - - private static void createTables() + private static void copyDatabase() { - conn.Open(); + File.WriteAllBytes(@"\" + databaseName, Resources.saviour); + } - cmd.CommandText = "CREATE TABLE RecordSet (ID NTEXT PRIMARY KEY, Drive_Name NTEXT, Capacity INTEGER, File_System NTEXT, Type NTEXT);"; - cmd.ExecuteNonQuery(); - cmd.CommandText = "CREATE TABLE Properties (Property NTEXT PRIMARY KEY, value NTEXT);"; - cmd.ExecuteNonQuery(); + internal static void init() { + if (!File.Exists(databaseName)) { //if the database doesnt exists (program hasnt been run before) - conn.Close(); + } } } }