diff --git a/components/SQLCE4Umbraco/SqlCeApplicationBlock.cs b/components/SQLCE4Umbraco/SqlCeApplicationBlock.cs index 7cde110d77..5cd9bc2140 100644 --- a/components/SQLCE4Umbraco/SqlCeApplicationBlock.cs +++ b/components/SQLCE4Umbraco/SqlCeApplicationBlock.cs @@ -102,8 +102,6 @@ namespace SqlCE4Umbraco Debug.WriteLine("----------------------------------------------------------------------------"); Debug.WriteLine(commandText); Debug.WriteLine("----------------------------------------------------------------------------"); - conn.ConnectionString = connectionString; - conn.Open(); SqlCeCommand cmd = new SqlCeCommand(commandText, conn); AttachParameters(cmd, commandParameters); rowsAffected = cmd.ExecuteNonQuery(); diff --git a/components/SQLCE4Umbraco/SqlCeContextGuardian.cs b/components/SQLCE4Umbraco/SqlCeContextGuardian.cs index 0597b87a3d..eb47a15bfe 100644 --- a/components/SQLCE4Umbraco/SqlCeContextGuardian.cs +++ b/components/SQLCE4Umbraco/SqlCeContextGuardian.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Data.Common; using System.Data.SqlServerCe; using System.Linq; @@ -9,7 +10,7 @@ namespace SQLCE4Umbraco { public static class SqlCeContextGuardian { - private static SqlCeConnection _conn; + private static SqlCeConnection _constantOpenConnection; private static object objLock = new object(); // Awesome SQL CE 4 speed improvement by Erik Ejskov Jensen - SQL CE 4 MVP @@ -27,15 +28,28 @@ namespace SQLCE4Umbraco } connectionStringBuilder.Remove("datalayer"); + // SQL CE 4 performs better when there's always a connection open in the background + ensureOpenBackgroundConnection(connectionStringBuilder.ConnectionString); + + SqlCeConnection conn = new SqlCeConnection(connectionStringBuilder.ConnectionString); + conn.Open(); + + return conn; + + } + + private static void ensureOpenBackgroundConnection(string connectionString) + { lock (objLock) { - if (_conn != null) - throw new InvalidOperationException("Already opened"); - _conn = new SqlCeConnection(connectionStringBuilder.ConnectionString); - _conn.Open(); + if (_constantOpenConnection == null) + { + _constantOpenConnection = new SqlCeConnection(connectionString); + _constantOpenConnection.Open(); + } + else if (_constantOpenConnection.State != ConnectionState.Open) + _constantOpenConnection.Open(); } - - return _conn; } } } diff --git a/umbraco/presentation/install/steps/database.ascx b/umbraco/presentation/install/steps/database.ascx index 4be5eea0a4..82f0c5313d 100644 --- a/umbraco/presentation/install/steps/database.ascx +++ b/umbraco/presentation/install/steps/database.ascx @@ -126,7 +126,7 @@

Missing files: SQL CE 4 requires that you manually add the SQL CE 4 runtime to your Umbraco installation.
- You can either use the following instructions on how to add SQL CE 4 or select another database type from the dropdown above.