SqlCeConnection.GetDatabaseInfo メソッド

接続されているデータベースのロケール情報、暗号化モード、および大文字と小文字の区別に関するキーと値のペアを返します。

名前空間:  System.Data.SqlServerCe
アセンブリ:  System.Data.SqlServerCe (System.Data.SqlServerCe.dll)

構文

'宣言
<SecurityCriticalAttribute> _
<SecurityTreatAsSafeAttribute> _
<SecurityPermissionAttribute(SecurityAction.Assert, UnmanagedCode := True)> _
Public Function GetDatabaseInfo As List(Of KeyValuePair(Of String, String))
'使用
Dim instance As SqlCeConnection
Dim returnValue As List(Of KeyValuePair(Of String, String))

returnValue = instance.GetDatabaseInfo()
[SecurityCriticalAttribute]
[SecurityTreatAsSafeAttribute]
[SecurityPermissionAttribute(SecurityAction.Assert, UnmanagedCode = true)]
public List<KeyValuePair<string, string>> GetDatabaseInfo()
[SecurityCriticalAttribute]
[SecurityTreatAsSafeAttribute]
[SecurityPermissionAttribute(SecurityAction::Assert, UnmanagedCode = true)]
public:
List<KeyValuePair<String^, String^>>^ GetDatabaseInfo()
[<SecurityCriticalAttribute>]
[<SecurityTreatAsSafeAttribute>]
[<SecurityPermissionAttribute(SecurityAction.Assert, UnmanagedCode = true)>]
member GetDatabaseInfo : unit -> List<KeyValuePair<string, string>> 
public function GetDatabaseInfo() : List<KeyValuePair<String, String>>

戻り値

型: System.Collections.Generic.List<KeyValuePair<String, String>>
ロケール、暗号化モード、および大文字と小文字の区別に関する名前と値のペアの並べ替えられたリスト。

説明

暗号化オプション、platform default、および engine default の詳細については、「データベースの暗号化」を参照してください。

使用例

以下の例では、GetDatabaseInfo を使って、Northwind.sdf のデータベース プロパティを取得しています。SqlCeConnection に接続文字列が渡され、データベースへの接続が開かれます。接続が開かれた後は、GetDatabaseInfo の内容は KeyValuePair に格納され、コンソールに表示されます。

Dim connStr As String = Nothing
Dim databasePath As String = Nothing
Dim sqlconn As SqlCeConnection = Nothing

Try
    '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='password'"

    'Connecting to the database and opening the connection
    sqlconn = New SqlCeConnection(connStr)
    sqlconn.Open()

    'Retrieving the database information
    Dim dbinfo As List(Of KeyValuePair(Of String, String)) = sqlconn.GetDatabaseInfo

    Console.WriteLine("GetDatabaseInfo() results:")
    Dim kvp As KeyValuePair(Of String, String)

    For Each kvp In dbinfo
        Console.WriteLine(kvp)
    Next

Catch ex As Exception
    Console.WriteLine(ex.Message)

Finally
    'Dispose the connection's resources
    sqlconn.Dispose()

    Console.WriteLine(vbNewLine & vbNewLine & vbNewLine & "Press any key to continue...")
    Console.Read()
End Try
string connStr = null;
string databasePath = null;
SqlCeConnection sqlconn = null;

try
{
    //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);
    sqlconn.Open();

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

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

    foreach (KeyValuePair<string, string> kvp in dbinfo)
    {
        Console.WriteLine(kvp);
    }

}
catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}
finally
{
    //Dispose the connection's resources
    sqlconn.Dispose();

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

関連項目

参照

SqlCeConnection クラス

System.Data.SqlServerCe 名前空間