1
Fork 0

removed code for making database, premade one used instead.

This commit is contained in:
Jake Howard 2014-11-09 18:18:09 +00:00
parent 544c8b961c
commit 0733463b36

View file

@ -6,69 +6,26 @@ using System.Threading.Tasks;
using System.Data.SqlServerCe; using System.Data.SqlServerCe;
using System.Data; using System.Data;
using System.IO; using System.IO;
using Saviour_Backup_System.Properties;
namespace Saviour_Backup_System namespace Saviour_Backup_System
{ {
class databaseTools class databaseTools
{ {
internal static string databaseName = "db.sdf"; internal static string databaseName = "saviour.sdf";
private static SqlCeConnection conn = new SqlCeConnection("Data Source = " + databaseName); private static SqlCeConnection conn = new SqlCeConnection("Data Source = " + databaseName + "; password=12a712d7e6f71ed07822c219318da2c0"); //password is a hash
private static SqlCeCommand cmd = conn.CreateCommand(); private static SqlCeCommand cmd = conn.CreateCommand();
internal static void init(){ private static void copyDatabase()
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()
{ {
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);"; internal static void init() {
cmd.ExecuteNonQuery(); if (!File.Exists(databaseName)) { //if the database doesnt exists (program hasnt been run before)
conn.Close(); }
} }
} }
} }