public static void Main() { // Enable nice styles in XP/Vista/7. Application.EnableVisualStyles(); // Store title which can be shown in all message boxes etc. AppGlobals.AppName = $"{Application.ProductName} {AppGlobals.AppVersion()}"; // Test for existence of database. bool databaseExists = false; string databasePath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\RoadMusic\\RoadMusic.db"; // Set database connection string across whole app. DatabaseSettings.DatabasePath = databasePath; DatabaseSettings.ConnectionString = $"Data Source={databasePath}"; // If database not found... if (!File.Exists(databasePath)) { // Try to create a blank database. try { DbCreate.CreateDatabase(databasePath); // Database now exists. databaseExists = true; } catch (Exception ex) { MessageBox.Show($"{ex.Message} The program cannot start.", AppGlobals.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { // Database already exists. databaseExists = true; } // Only start the app if the database exists... if (databaseExists) { // Set where registry access happens across whole app. RegistryAccess.SetSoftwareKey($"Software\\{Application.ProductName}"); // Show the main form. try { Application.Run(new MainForm()); } catch (Exception ex) { MessageBox.Show($"Sorry, a fatal error occurred : {ex.Message}", AppGlobals.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public bool CreateDatabase(string databaseName, ODatabaseType databaseType, OStorageType storageType) { DbCreate operation = new DbCreate(); operation.DatabaseName = databaseName; operation.DatabaseType = databaseType; operation.StorageType = storageType; ODocument document = _connection.ExecuteOperation(operation); return(document.GetField <bool>("IsCreated")); }
static void Main(string[] args) { string[] dbnames = new string[] { "TestDataBase1" }; string[] cons = new string[] { "server=.;user id = sa; password=11111111;database=TestDataBase1;Max Pool Size=50;Min Pool Size=2", }; DbCreate dbCreate = new DbCreate(); dbCreate.DbCreateInfos(dbnames, cons, true); }
public bool CreateDatabase(string databaseName, ODatabaseType databaseType, OStorageType storageType) { var operation = new DbCreate { DatabaseName = databaseName, DatabaseType = databaseType, StorageType = storageType }; var document = _connection.ExecuteOperation(operation); return(document.GetField <bool>("IsCreated")); }
public static void ClassInit(TestContext context) { var haha = new DbCreate(); haha.CreateNewDb(); }