/// <summary> /// Applies the indices to the database. /// </summary> /// <param name="path">The path.</param> /// <param name="contentProtected">if set to <c>true</c> [content protected].</param> /// <param name="password">The password.</param> /// <remarks>Documented by Dev03, 2009-04-30</remarks> public static void ApplyIndicesToDatabase(string path, bool contentProtected, string password) { string connectionString = contentProtected ? MSSQLCEConn.GetFullConnectionString(path, password) : MSSQLCEConn.GetFullConnectionString(path); using (SqlCeConnection connection = new SqlCeConnection(connectionString)) { connection.Open(); ApplyIndicesToDatabase(connection); } }
/// <summary> /// Verifies the data base. /// </summary> /// <param name="path">The path.</param> /// <param name="contentProtected">if set to <c>true</c> [content protected].</param> /// <param name="password">The password.</param> /// <remarks>Documented by Dev03, 2009-04-30</remarks> public static void VerifyDataBase(string path, bool contentProtected, string password) { string connectionString = contentProtected ? MSSQLCEConn.GetFullConnectionString(path, password) : MSSQLCEConn.GetFullConnectionString(path); using (SqlCeEngine sqlEngine = new SqlCeEngine()) { sqlEngine.LocalConnectionString = connectionString; sqlEngine.Repair(connectionString, RepairOption.RecoverAllPossibleRows); sqlEngine.Shrink(); try { File.Delete(Path.ChangeExtension(path, ".log")); } catch { Debug.WriteLine("Can not delete logfile "); } } }