LoadProperties メソッド

同期プロパティに保存されたすべての値を取得し、その保存値を SqlCeReplication クラス プロパティに入力します。

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

構文

'宣言
Public Function LoadProperties As Boolean
'使用
Dim instance As SqlCeReplication
Dim returnValue As Boolean

returnValue = instance.LoadProperties()
public bool LoadProperties()
public:
bool LoadProperties()
member LoadProperties : unit -> bool 
public function LoadProperties() : boolean

戻り値

型: System. . :: . .Boolean

説明

LoadProperties 関数を正常に実行するには、SubscriberConnectionString 内に指定されたデータベースにあるサブスクリプションが 1 つだけの場合を除き、すべての SqlCeReplication オブジェクト プロパティを指定する必要があります。データベースを 1 つのパブリケーションだけにサブスクライブする場合、次のプロパティを省略できます。

データベース内に複数のサブスクリプションが存在する場合に、これらのプロパティを設定せずに LoadProperties を呼び出すと、データベース内の各サブスクリプションに対してエラーが発生します。コレクション内の各エラーには、データベース内の各サブスクリプションに対する PublisherPublication、および PublisherDatabase の各プロパティが含まれます。

SaveProperties を呼び出すと、パスワード プロパティの値がデータベースに格納されます。これらの値は、一意のデバイス ハードウェア キーを使用して、自動的に暗号化されます。そのため、1 つのデバイス (またはサーバー) についてサブスクリプション プロファイルを作成し、そのデータベースを新しいデバイスにコピーすると、LoadProperties がプロファイルからのパスワード取得に失敗します。正しいパスワードを手動で指定し、SaveProperties を再度呼び出すと、新しいデバイスのプロファイルを保持できます。

使用例

LoadProperties メソッドを使用する方法の例を次に示します。

Try
    '
    'NOTE: when possible, prompt users to enter security 
    'credentials at runtime. If you store credentials in a file, 
    'you must secure the file to prevent unauthorized access.
    '
    Dim repl As New SqlCeReplication()
    repl.SubscriberConnectionString = "Data Source='Test.sdf'; Pwd='<enterStrongPassword>'"
    repl.LoadProperties()

    repl.Synchronize()
Catch
    ' Handle errors here
End Try
try
{
    //NOTE: when possible, prompt users to enter security 
    //credentials at runtime. If you store credentials in a file, 
    //you must secure the file to prevent unauthorized access.
    //
    SqlCeReplication repl = new SqlCeReplication();
    repl.SubscriberConnectionString = "Data Source='Test.sdf'; Pwd='<enterStrongPassword>'";
    repl.LoadProperties();

    repl.Synchronize();
}
catch (SqlCeException)
{
    // Handle errors here
}

関連項目

参照

SqlCeReplication クラス

SqlCeReplication メンバー

System.Data.SqlServerCe 名前空間