SqlCeEngine.Upgrade Method (String)

Upgrades a SQL Server Compact database from version 3.1 to 3.5. The destination database will be encrypted if the encryption mode was specified in the Destination Connection string. The collation of the database will be case sensitive if the case-sensitive property is set to true in the connection string.

Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)

Syntax

'Declaration
Public Sub Upgrade ( _
    destConnectionString As String _
)
public void Upgrade (
    string destConnectionString
)
public:
void Upgrade (
    String^ destConnectionString
)
public void Upgrade (
    String destConnectionString
)
public function Upgrade (
    destConnectionString : String
)

Parameters

  • destConnectionString
    The connection string to the destination database.

Example

The following sample demonstrates how to upgrade a previously created SQL Server Compact 3.5 database to a case-sensitive SQL Server Compact 3.5 database.

/// <summary>
/// Demonstrates how to upgrade a database with case sensitivity.
/// </summary>
public static void UpgradeDatabasewithCaseSensitive()
{
   // <Snippet2>
   // Default case-insentive connection string.
   // Note that Nortwind.sdf is an old 3.1 version database.

   string connStringCI = "Data Source= Northwind.sdf; LCID= 1033";

   // Set "Case Sensitive" to true to change the collation from CI to CS.
    string connStringCS = "Data Source= Northwind.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);
   }
   // </Snippet2>

}

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Vista, Windows Mobile 5.0, Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Mobile 2003 for Pocket PC, Windows CE 5.0
Version Information
.NET Framework and NET Compact Framework
Supported in 3.5
.NET Framework
Supported in 3.0
.NET Compact Framework and .Net Framework
Supported in 2.0

See Also

Reference

SqlCeEngine Class
SqlCeEngine Members
System.Data.SqlServerCe Namespace