public static void UpgradeDataBase() { string connStringCI = "Data Source= SmartCA.sdf; LCID= 1033"; // Set "Case Sensitive" to true to change the collation from CI to CS. string connStringCS = "Data Source= SmartCA.sdf; LCID= 1033; Case Sensitive=true"; SqlCeEngine engine = new SqlCeEngine(connStringCI); // The collation of the database will be case sensitive because of // the new connection string used by the Upgrade method. engine.Upgrade(connStringCS); SqlCeConnection conn = null; conn = new SqlCeConnection(connStringCI); conn.Open(); //Retrieve the connection string information - notice the 'Case Sensitive' value. List <KeyValuePair <string, string> > dbinfo = conn.GetDatabaseInfo(); Console.WriteLine("\nGetDatabaseInfo() results:"); foreach (KeyValuePair <string, string> kvp in dbinfo) { Console.WriteLine(kvp); } }
public void UpgradeTo40(string connectionString) { string filename; using (SqlCeConnection conn = new SqlCeConnection(connectionString)) { filename = conn.Database; } if (filename.Contains("|DataDirectory|")) { throw new ApplicationException("DataDirectory macro not supported for upgrade"); } SQLCEVersion fileversion = DetermineVersion(filename); if (fileversion == SQLCEVersion.SQLCE20) { throw new ApplicationException("Unable to upgrade from 2.0 to 4.0"); } if (SQLCEVersion.SQLCE40 > fileversion) { SqlCeEngine engine = new SqlCeEngine(connectionString); engine.Upgrade(); } }
/// <summary> /// 首先建议你使用 SQL Server Management Studio 2012 这个版本来创建SQLCE数据库, /// 因为这样才是4.0的版本,我使用2008的版本创建出来是3.5的,所以只能使用SQLCE 3.5的引用。 /// </summary> internal void Upgrade() { using (SqlCeEngine engine = new SqlCeEngine(CONNECTION_STRING)) { engine.Upgrade(); } }
/// <summary> /// Demonstrates how to upgrade a database with case sensitivity. /// </summary> public static void UpgradeDatabasewithCaseSensitive(string filePath) { // <Snippet2> // Default case-insentive connection string. // Note that Northwind.sdf is an old 3.1 version database. string connStringCI = $"Data Source= {filePath}; LCID= 1033"; // Set "Case Sensitive" to true to change the collation from CI to CS. string connStringCS = $"Data Source= {filePath}; LCID= 1033; Case Sensitive=true"; SqlCeEngine engine = new SqlCeEngine(connStringCI); // The collation of the database will be case sensitive because of // the new connection string used by the Upgrade method. engine.Upgrade(connStringCS); SqlCeConnection conn = null; conn = new SqlCeConnection(connStringCI); conn.Open(); //Retrieve the connection string information - notice the 'Case Sensitive' value. List <KeyValuePair <string, string> > dbinfo = conn.GetDatabaseInfo(); Console.WriteLine("\nGetDatabaseInfo() results:"); foreach (KeyValuePair <string, string> kvp in dbinfo) { Console.WriteLine(kvp); } // </Snippet2> }
public static DataTable GetDataTable(string tablename) { if (!LayoutControl.IsInDesignMode) { using (SqlCeConnection con = new SqlCeConnection(string.Format(@"Data Source = {0}", LayoutControl.FindFile("Northwind.sdf")))) { #if !Framework3_5 try { if (!Upgraded) { SqlCeEngine engine = new SqlCeEngine(string.Format(@"Data Source = {0}", LayoutControl.FindFile("Northwind.sdf"))); engine.Upgrade(); Upgraded = true; } } catch (Exception) { } #endif con.Open(); SqlCeDataAdapter sda = new SqlCeDataAdapter(string.Format("SELECT * FROM {0}", tablename), con); DataSet ds = new DataSet(); sda.Fill(ds); return(ds.Tables[0]); } } return(new DataTable()); }
internal static string UpgradeDB() { string connStringCI = "Data Source= Shop.sdf; LCID= 1049"; // Set "Case Sensitive" to true to change the collation from CI to CS. string connStringCS = "Data Source= Shop.sdf; LCID= 1049; Case Sensitive=true"; SqlCeEngine engine = new SqlCeEngine(connStringCI); // The collation of the database will be case sensitive because of // the new connection string used by the Upgrade method. engine.Upgrade(connStringCS); SqlCeConnection conn = null; conn = new SqlCeConnection(connStringCI); conn.Open(); //Retrieve the connection string information - notice the 'Case Sensitive' value. List <KeyValuePair <string, string> > dbinfo = conn.GetDatabaseInfo(); Console.WriteLine("\nGetDatabaseInfo() results:"); foreach (KeyValuePair <string, string> kvp in dbinfo) { Console.WriteLine(kvp); } return("Shop.sdf has been upgraded to Ver. 4.0. Please rerun the program."); }
private void Form1_Load(object sender, EventArgs e) { string cs = GetConnectionString(); //need to upgrade to sql engine v4.0? if (!IsV40Installed()) { SqlCeEngine engine = new SqlCeEngine(cs); engine.Upgrade(); } //open connection SqlCeConnection sc = new SqlCeConnection(cs); //query customers string sql = "SELECT * FROM Customers"; SqlCeCommand cmd = new SqlCeCommand(sql, sc); //create grid SqlCeDataAdapter sda = new SqlCeDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); dataGridView1.DataSource = dt; dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader); //close connection sc.Close(); }
/// <summary> /// The OpenSqlCeConnection. /// </summary> private static void OpenSqlCeConnection() { try { _con = new SqlCeConnection(@"Data Source=D:\AnnaBaba\BabaDress.sdf;"); _con.Open(); } catch (SqlCeInvalidDatabaseFormatException ex) { string connStringCI = @"Data Source=D:\AnnaBaba\ABCAnadhanamDetails.sdf; LCID= 1033"; string connStringCS = @"Data Source=D:\AnnaBaba\ABCAnadhanamDetails.sdf; LCID= 1033; Case Sensitive=true"; SqlCeEngine engine = new SqlCeEngine(connStringCI); engine.Upgrade(connStringCS); _con = null; _con = new SqlCeConnection(connStringCI); _con.Open(); } catch (SqlCeException ex) { MessageBox.Show(ex.Message, "Annadhanam", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Annadhanam", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } }
public void Upgrade() { var file = new FileInfo(new SqlConnectionStringBuilder(ConnectionString).DataSource); var appData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SQLCE Code Generator"); if (!Directory.Exists(appData)) { Directory.CreateDirectory(appData); } var newFile = file.CopyTo(Path.Combine(appData, file.Name), true); var newConnString = new SqlConnectionStringBuilder(ConnectionString) { DataSource = newFile.FullName }; var firstIdx = newConnString.ToString().IndexOf("\"", 0, StringComparison.Ordinal); var lastIdx = newConnString.ToString().LastIndexOf("\"", StringComparison.Ordinal); var connStr = new StringBuilder(newConnString.ToString()); connStr[firstIdx] = '\''; connStr[lastIdx] = '\''; ConnectionString = connStr.ToString(); using (var engine = new SqlCeEngine(ConnectionString)) engine.Upgrade(); using (var connection = new SqlCeConnection(ConnectionString)) connection.Open(); }
/// <summary> /// Gets a new database connection, open. /// </summary> /// <param name="connString">The connection string.</param> /// <returns>The connection.</returns> public DbConnection GetConnection(string connString) { if (connection == null || connection.ConnectionString != connString) { connection = new SqlCeConnection(connString); } if (connection.State != System.Data.ConnectionState.Open) { try { connection.Open(); } catch (System.Data.SqlServerCe.SqlCeInvalidDatabaseFormatException) { // TODO: Delete in release // Convert DB to CE v.4 SqlCeEngine engine = new SqlCeEngine(connString); engine.Upgrade(connString); connection = new SqlCeConnection(connString); connection.Open(); } catch (Exception) { throw; } } return(connection); }
public static SqlCeConnection GetSqlCeConnection() { lock (_lockLocal) { if (_sqlCeConnection == null) { throw new Exception("SqlCE connection not initialized: use InitSqlConnection"); } if (_sqlCeConnection.State == ConnectionState.Closed || _sqlCeConnection.State == ConnectionState.Broken) { _logger.Info("Open connection to local database:"); try { _sqlCeConnection.Open(); } catch (SqlCeInvalidDatabaseFormatException ex) { _logger.ErrorFormat("Cannot open local database: {0}", ex.Message); var sqlEngine = new SqlCeEngine(_sqlCeConnection.ConnectionString); _logger.Info("Upgrade local database"); sqlEngine.Upgrade(); _logger.Debug("Open connection to local database after upgrade:"); _sqlCeConnection.Open(); } } } return(_sqlCeConnection); }
public static DataTable ExecuteSqlQuery(string query, params SqlCeParameter[] sqlParams) { var dt = new DataTable(); using (var conn = new SqlCeConnection(connStr)) using (var cmd = new SqlCeCommand(query, conn)) { try { SqlCeEngine engine = new SqlCeEngine(conn.ConnectionString); engine.Upgrade(conn.ConnectionString); } catch { } cmd.CommandType = CommandType.Text; cmd.Parameters.AddRange(sqlParams); conn.Open(); dt.Load(cmd.ExecuteReader()); } return dt; }
public void UpgradeWithCaseSens() { SqlCeEngine Engine = new SqlCeEngine(ConnStringCI); Engine.Upgrade(ConnStringCS); SQLconn = new SqlCeConnection(ConnStringCI); SQLconn.Open(); }
public void UpgrateSQLServerCe() { SqlCeEngine engine = new SqlCeEngine(getConnectionString()); // https://msdn.microsoft.com/en-us/library/bb896160.aspx engine.Upgrade(getConnectionString()); }
public void Upgrade() { using (SqlCeEngine engine = new SqlCeEngine(_connString)) { engine.Upgrade(); engine.Dispose(); } }
/// <summary> /// 将数据格式升级到4.0版本 /// </summary> /// <param name="fileName">要升级的文件</param> /// <param name="UserName"></param> /// <param name="passWord"></param> public static void UpdateSqlCe(string fileName, string userName, string passWord) { try { SqlCeEngine sql = new SqlCeEngine(string.Format("Data Source={0};Max Database Size=4091;Persist Security Info=False;password='******';", fileName, passWord)); sql.Upgrade(); } catch (Exception e) { All.Class.Error.Add(e); } }
private void Upgrade() { try { const string connectionString = @"Data Source=App_Data\tests.sdf"; var ce = new SqlCeEngine(connectionString); ce.Upgrade(connectionString); } catch (Exception) { // throw; } }
public MainWindow() { InitializeComponent(); SqlCeConnection connection = new SqlCeConnection("Data Source=Panic.sdf"); // Upgrade the database if required SqlCeEngine engine = new SqlCeEngine(connection.ConnectionString); engine.Upgrade(); siteRepository = new SiteSQL(connection); linkRepository = new LinkSQL(connection); hardwareRepository = new HardwareSQL(connection); graphVisualiser.InitialiseRepository(siteRepository, linkRepository); dataConfiguration.InitialiseRepository(siteRepository, linkRepository, hardwareRepository); graphVisualiser.Refresh(); }
public override void PrepareEngine(string connectionString, DbConnection connection) { try { connection.Open(); } catch { SqlCeEngine e = new SqlCeEngine(connectionString); e.Upgrade(); } finally { connection.Close(); } }
public Form1() { InitializeComponent(); strCon = @"Data Source=..\..\..\..\..\..\common\Data\Diagram\db\Diagram.sdf"; //upgrade the db to make it compatible try { SqlCeEngine dbEngine = new SqlCeEngine(strCon); dbEngine.Upgrade(); } catch (Exception) { } }
public LocalDatabase(string FilePath) : base() { try { string fileName = Path.Combine(FilePath, "caselist.sdf"); connectionString = string.Format("Data Source=\"{0}\"", fileName); SqlCeEngine en = new SqlCeEngine(connectionString); if (!File.Exists(fileName)) { en.CreateDatabase(); } m_connection = new SqlCeConnection(); m_connection.ConnectionString = connectionString; if (m_connection.State == System.Data.ConnectionState.Closed) { try { m_connection.Open(); } catch (SqlCeInvalidDatabaseFormatException) { en.Upgrade(); m_connection.Open(); } } SqlCeCommand SelectTableCommand = new SqlCeCommand(); SelectTableCommand.CommandText = QuerySelectRowString; SelectTableCommand.Connection = m_connection; m_adapter = new SqlCeDataAdapter((SqlCeCommand)SelectTableCommand); // Create the DbCommandBuilder. m_builder = new SqlCeCommandBuilder(); m_builder.DataAdapter = m_adapter; m_adapter.SelectCommand = SelectTableCommand; } catch { throw; } }
public static void Ensure40(string fileName, string password = null) { string connectionString = GetConnectionString(fileName, password); var engine = new SqlCeEngine(connectionString); SQLCEVersion fileversion = DetermineVersion(fileName); if (fileversion == SQLCEVersion.SQLCE20) { throw new ApplicationException("Unable to upgrade from 2.0 to 4.0"); } if (SQLCEVersion.SQLCE40 > fileversion) { engine.Upgrade(); } }
public static SqlCeDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText, params SqlCeParameter[] commandParameters) { if (connectionString == null || connectionString.Length == 0) { throw new ArgumentNullException("connectionString"); } SqlCeConnection connection = null; try { connection = new SqlCeConnection(connectionString); try { connection.Open(); } catch (SqlCeInvalidDatabaseFormatException) { using (SqlCeEngine engine = new SqlCeEngine()) { engine.Upgrade(connectionString); } connection = new SqlCeConnection(connectionString); connection.Open(); } using (SqlCeCommand command = new SqlCeCommand()) { PrepareCommand( command, connection, null, commandType, commandText, commandParameters); return(command.ExecuteReader(CommandBehavior.CloseConnection)); } } catch { if ((connection != null) && (connection.State == ConnectionState.Open)) { connection.Close(); } throw; } }
public static void EnsureVersion40(this SqlCeEngine engine, string filename) { SQLCEVersion fileversion = DetermineVersion(filename); if (fileversion == SQLCEVersion.SQLCE20) { throw new ApplicationException("Unable to upgrade from 2.0 to 4.0"); } if (SQLCEVersion.SQLCE40 > fileversion) { // Original-Datei sichern string filenameBackup = GetBackupFilename(filename); File.Copy(filename, filenameBackup); engine.Upgrade();//string.Format("Data Source=\"{0}\"", filename+".new")); } }
public static SqlCeConnection GetOpenSettingsConnection() { if (_settingsConn.State != System.Data.ConnectionState.Open) { try { _settingsConn.Open(); } catch (SqlCeInvalidDatabaseFormatException) { SqlCeEngine engine = new SqlCeEngine(_settingsConn.ConnectionString); engine.Upgrade(); _settingsConn.Open(); } } return(_settingsConn); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); int upgrade = int.Parse(Upgrade); if (upgrade == 0) { SqlCeEngine engine = new SqlCeEngine(DataSource); engine.Upgrade(DataSource); UpdateSetting("upgrade", "1"); } Application.Run(new Form1()); }
/// <summary> /// Tries to establish a connection to the given database. If this fails with a <see cref="SqlCeInvalidDatabaseFormatException"/>, we try /// to update the database to current engine version. /// </summary> /// <param name="engine">Database engine instance to upgrade.</param> protected void CheckUpgrade(SqlCeEngine engine) { try { using (SqlCeConnection conn = new SqlCeConnection(_connectionString)) { conn.Open(); conn.Close(); } } catch (SqlCeInvalidDatabaseFormatException) { ServiceRegistration.Get <ILogger>().Warn("Upgrading existing SQL CE database format to v4.0..."); engine.Upgrade(); ServiceRegistration.Get <ILogger>().Warn("Upgrade successful!"); } }
private static void Update() { if (NoUpdate) { return; } SqlCeEngine engine = new SqlCeEngine(GetConnectionString()); try { NoUpdate = true; engine.Upgrade(); } catch (SqlCeException ceException) { System.Diagnostics.Debug.WriteLine(ceException.Message); System.Diagnostics.Debug.WriteLine("アップデートする必要はありませんでした。処理を続行します。"); } }
public void UpgradeTo40(string connectionString) { string filename; using (SqlCeConnection conn = new SqlCeConnection(connectionString)) { filename = conn.Database; } if (filename.Contains("|DataDirectory|")) throw new ApplicationException("DataDirectory macro not supported for upgrade"); SQLCEVersion fileversion = DetermineVersion(filename); if (fileversion == SQLCEVersion.SQLCE20) throw new ApplicationException("Unable to upgrade from 2.0 to 4.0"); if (SQLCEVersion.SQLCE40 > fileversion) { SqlCeEngine engine = new SqlCeEngine(connectionString); engine.Upgrade(); } }
public static void ExequteSqlCommand(string command, params SqlCeParameter[] sqlParams) { using (var conn = new SqlCeConnection(connStr)) using (var cmd = new SqlCeCommand(command, conn)) { try { SqlCeEngine engine = new SqlCeEngine(conn.ConnectionString); engine.Upgrade(conn.ConnectionString); } catch { } cmd.CommandType = CommandType.Text; cmd.Parameters.AddRange(sqlParams); conn.Open(); cmd.ExecuteReader(); } }
public static void UpgradeDatabase(string connectionString) { try { using (SqlCeEngine sqlCeEngine = new SqlCeEngine(connectionString)) { sqlCeEngine.Upgrade(); } } catch (Exception ex) { if (ex.Message.ToLower().Contains("database upgrade is not required")) { // do nothing -- the database has already been upgraded } else { throw; } } }
private TableCache(string connectionString) { try { MyConnection = new SqlCeConnection(connectionString); if (!hasUpgradeBeenTested) { try { var b = new SqlCeEngine(MyConnection.ConnectionString); b.Upgrade(); } catch (SqlCeException) { } hasUpgradeBeenTested = true; } MyConnection.Open(); LoadFromDatabase(); } catch (Exception e) { System.Diagnostics.Trace.WriteLine("TableCache, Ex : " + e.Message); } }
public bool Verify() { bool result = false; using (SqlCeEngine engine = new SqlCeEngine(_connString)) { result = engine.Verify(VerifyOption.Enhanced); if (!result) { try { engine.Upgrade(); } catch (Exception) { }; if (!engine.Verify(VerifyOption.Enhanced)) { engine.Repair(null, RepairOption.RecoverCorruptedRows); } result = engine.Verify(VerifyOption.Enhanced); } engine.Dispose(); } return(result); }
public static SqlCeDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText, params SqlCeParameter[] commandParameters) { if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString"); SqlCeConnection connection = null; try { connection = new SqlCeConnection(connectionString); try { connection.Open(); } catch (SqlCeInvalidDatabaseFormatException) { using (SqlCeEngine engine = new SqlCeEngine()) { engine.Upgrade(connectionString); } connection = new SqlCeConnection(connectionString); connection.Open(); } using (SqlCeCommand command = new SqlCeCommand()) { PrepareCommand( command, connection, null, commandType, commandText, commandParameters); return command.ExecuteReader(CommandBehavior.CloseConnection); } } catch { if ((connection != null) && (connection.State == ConnectionState.Open)) { connection.Close(); } throw; } }
private void butOpen_Click(object sender, RoutedEventArgs e) { string dbName = txtDbPath.Text; string dbPwd = txtPwd.Password; if (string.IsNullOrEmpty(dbName)) { "Please input database name".Notify(); return; } if (Utility.DetectNetworkDriver.IsPathOnNetworkDrive(dbName)) { "SQLCE do not support open from network".Notify(); return; } OpenModeClass CurOpenMode = null; if (cmbOpenMode.SelectedItem == null) { CurOpenMode = cmbOpenMode.Items[0] as OpenModeClass; } else { CurOpenMode = cmbOpenMode.SelectedItem as OpenModeClass; } uint maxDbSize = (uint)txtMaxDBSize.Value; //If open db ok ,and get tables info ok , then do //otherwise do nothing try { App.MainEngineer = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.SqlCE35).X_Handler; App.MainEngineer.Open(new LoginInfo_SSCE() { DbName = dbName, Pwd = txtPwd.Password, CurOpenMode = CurOpenMode.mode, MaxDbSize = maxDbSize }); } catch (SqlCeInvalidDatabaseFormatException sqe) { Debug.WriteLine("*****************" + sqe.Message); #region if (wf.DialogResult.Yes == wf.MessageBox.Show("Your database format is old version ,do you want to upgrade it ,so this software can modify it?", "Warning", wf.MessageBoxButtons.YesNo, wf.MessageBoxIcon.Question, wf.MessageBoxDefaultButton.Button1)) { try { if (Properties.Settings.Default.AutoBackupOldVersionFileBeforeUpgrade) { if (!Directory.Exists(Config.AutoBackupFolder)) { Directory.CreateDirectory(Config.AutoBackupFolder); } File.Copy(dbName, Config.AutoBackupFolder + Path.GetFileName(dbName), true); } } catch (Exception ee) { #if DEBUG throw ee; #else ee.Message.Show(); #endif } SqlCeEngine d = new SqlCeEngine(CoreEA.ConnSTR.DbConnectionString.SSCE.GetSSCEConnectionString( dbName, dbPwd, (bool)chkIsEncrypted.IsChecked, CurOpenMode)); try { d.Upgrade(); "Upgrade Successful".Notify(); } catch (Exception dee) { dee.Message.Notify(); App.ResetMainEngineer(); return; } goto ReOpen; } else { App.ResetMainEngineer(); return; } #endregion } catch (Exception eee) { eee.Message.Notify(); } ReOpen: if (App.MainEngineer.IsOpened) { App.MainEngineer.CurDatabase = dbName; App.MainEngineer.CurPwd = txtPwd.Password; //this.Hide(); txtDbPath.Text = string.Empty; txtPwd.Password = string.Empty; Properties.Settings.Default.LastestOpenedDb = dbName; Properties.Settings.Default.LastestOpenedDbPwd = dbPwd; Properties.Settings.Default.Save(); #region Save to Opened History Info SSCEObjects ssceItem = new SSCEObjects(); ssceItem.DbFileFullPath = dbName; if (!SerializeClass.DatabaseHistoryInfo.SSCEHistory.IsContainSubValue(ssceItem.DbFileFullPath)) { HistoryObject oldObject = SerializeClass.DatabaseHistoryInfo; ssceItem.LatestVisitTime = DateTime.Now; oldObject.SSCEHistory.Add(ssceItem); SerializeClass.DatabaseHistoryInfo = oldObject; } #endregion RefreshLastOpenedDbsStatus(); RibbionIDE ide = new RibbionIDE(); ide.WindowState = WindowState.Maximized; ide.BringIntoView(); ide.ShowDialog(); } else { App.ResetMainEngineer(); } }
protected override DbConnection CreateConnection(Type t, string connectionString) { SqlCeConnection connection = null; try { connection = new SqlCeConnection(connectionString); connection.Open(); } catch (System.Data.SqlServerCe.SqlCeInvalidDatabaseFormatException) { try { var engine = new SqlCeEngine(connectionString); engine.Upgrade(); try { connection = new SqlCeConnection(connectionString); connection.Open(); } catch (System.Exception){} } catch (System.Exception ex) { Console.WriteLine("Attempt on Upgrading SQL CE Database Failed (Reason = \"" + ex.Message + "\")"); } } catch (Exception ex) { Console.WriteLine("Unexpected Error Occurred ! Error Details : " + ex.Message); } return connection; }
/// <summary> /// /// </summary> public override void Upgrade() { SqlCeEngine s = new SqlCeEngine(ConnectionString); s.Upgrade(); }
/// <summary> /// Tries to establish a connection to the given database. If this fails with a <see cref="SqlCeInvalidDatabaseFormatException"/>, we try /// to update the database to current engine version. /// </summary> /// <param name="engine">Database engine instance to upgrade.</param> protected void CheckUpgrade(SqlCeEngine engine) { try { using (SqlCeConnection conn = new SqlCeConnection(_connectionString)) { conn.Open(); conn.Close(); } } catch (SqlCeInvalidDatabaseFormatException) { ServiceRegistration.Get<ILogger>().Warn("Upgrading existing SQL CE database format to v4.0..."); engine.Upgrade(); ServiceRegistration.Get<ILogger>().Warn("Upgrade successful!"); } }
public static void Upgrade() { System.Data.SqlServerCe.SqlCeEngine engine = new SqlCeEngine("Data Source = 'Database.sdf'"); engine.Upgrade(); }
public static SqlCeConnection GetOpenSettingsConnection() { if (_settingsConn.State != System.Data.ConnectionState.Open) { try { _settingsConn.Open(); } catch (SqlCeInvalidDatabaseFormatException) { SqlCeEngine engine = new SqlCeEngine(_settingsConn.ConnectionString); engine.Upgrade(); _settingsConn.Open(); } } return _settingsConn; }