Share via


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 _
)
'Usage
Dim instance As SqlCeEngine
Dim destConnectionString As String

instance.Upgrade(destConnectionString)
public void Upgrade(
    string destConnectionString
)
public:
void Upgrade(
    String^ destConnectionString
)
member Upgrade : 
        destConnectionString:string -> unit 
public function Upgrade(
    destConnectionString : String
)

Parameters

Examples

The following sample demonstrates how to upgrade a previously created database to a case-sensitive 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>

}

See Also

Reference

SqlCeEngine Class

SqlCeEngine Members

Upgrade Overload

System.Data.SqlServerCe Namespace