SqlCeConnection.GetDatabaseInfo Method

Returns a set of Key Value pairs with information about locale, encryption mode, and case-sensitivity setting of the connected database.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

[SecurityPermissionAttribute(SecurityAction.Assert, UnmanagedCode = true)]
public List<KeyValuePair<string, string>> GetDatabaseInfo()

Return Value

Type: System.Collections.Generic.List<KeyValuePair<String, String>>
Sorted list with the name value pairs of locale, encryption mode, and case sensitivity.

For more information about the encryption options, platform default and engine default, see Encrypting a Database

The following example uses the GetDatabaseInfo to retrieve the database properties of Northwind.sdf. The SqlCeConnection is passed a connection string and then opens a connection to the database. Once the connection is open, the contents of GetDatabaseInfo is stored in a KeyValuePair and displayed on the console.

string connStr = null;
string databasePath = null;
SqlCeConnection sqlconn = null;

    //Defining database parameters
    databasePath = @"C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Samples\Northwind.sdf";
    //If the database already exists, the existing encryption mode will supercede the supplied mode
    connStr = "Data Source=" + databasePath + ";Encryption Mode = 'ppc2003 compatibility';Password='sa'";

    //Connecting to the database and opening the connection
    sqlconn = new SqlCeConnection(connStr);

    //Retrieving the database information 
    List<KeyValuePair<string, string>> dbinfo = sqlconn.GetDatabaseInfo();

    Console.WriteLine("GetDatabaseInfo() results:");

    foreach (KeyValuePair<string, string> kvp in dbinfo)

catch (Exception ex)
    //Dispose the connection's resources

    Console.WriteLine("\n\n\nPress any key to continue...");