public ScimoreDb() { try { IPathManager pathManager = ServiceRegistration.Get <IPathManager>(); string dataDirectory = pathManager.GetPath("<DATA>"); string databasePath = Path.Combine(dataDirectory, DEFAULT_DATABASE_FILE); const string DATABASE_NAME = "MediaPortal"; _connectionString = "Initial Catalog=" + DATABASE_NAME; _db.Create(databasePath); _db.Open(databasePath); using (ScimoreConnection conn = _db.CreateConnection(_connectionString)) { using (IDbCommand command = conn.CreateCommand()) { command.CommandText = "CREATE DATABASE IF NOT EXISTS " + DATABASE_NAME; command.ExecuteNonQuery(); } } } catch (Exception e) { ServiceRegistration.Get <ILogger>().Critical("Error establishing database connection", e); throw; } }
private IDbConnection GetConnection() { IDbConnection conn = scimore.CreateConnection(); conn.Open(); return(conn); }