ReinitializeSubscription メソッド

再初期化するようサブスクリプションをマークします。このメソッドを呼び出した後で、アプリケーションで Synchronize メソッドを呼び出して、パブリケーションの最新のスナップショットをデバイスにダウンロードする必要があります。

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

構文

'宣言
Public Sub ReinitializeSubscription ( _
    uploadBeforeReinitialize As Boolean _
)
'使用
Dim instance As SqlCeReplication
Dim uploadBeforeReinitialize As Boolean

instance.ReinitializeSubscription(uploadBeforeReinitialize)
public void ReinitializeSubscription(
    bool uploadBeforeReinitialize
)
public:
void ReinitializeSubscription(
    bool uploadBeforeReinitialize
)
member ReinitializeSubscription : 
        uploadBeforeReinitialize:bool -> unit 
public function ReinitializeSubscription(
    uploadBeforeReinitialize : boolean
)

パラメーター

  • uploadBeforeReinitialize
    型: System. . :: . .Boolean
    True の場合は、サブスクライバ側でスナップショットを適用する前に、サブスクリプション データベースの変更がパブリッシャにアップロードされます。既定値は False です。

説明

SQL Server Compact 3.5 のサブスクリプション システム テーブルにフラグが付けられ、次の同期時にサブスクリプションを再初期化する必要があることを示します。ReinitializeSubscription メソッドを呼び出した後で、アプリケーションでは Synchronize メソッドを呼び出して、既存のレプリカを削除し、パブリケーションの新しいレプリカを Windows Mobile ベースのデバイスにダウンロードする必要があります。

使用例

Dim repl As SqlCeReplication = Nothing

Try
    ' Create SqlCeReplication instance
    '
    '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.
    '
    repl = New SqlCeReplication()
    repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa35.dll"
    repl.InternetLogin = "MyInternetLogin"
    repl.InternetPassword = "<enterStrongPassword>"
    repl.Publisher = "MyPublisher"
    repl.PublisherDatabase = "MyPublisherDatabase"
    repl.PublisherLogin = "MyPublisherLogin"
    repl.PublisherPassword = "<enterStrongPassword>"
    repl.Publication = "MyPublication"
    repl.Subscriber = "MySubscriber"
    repl.SubscriberConnectionString = "Data Source=MyDatabase.sdf"

    ' Mark the subscription for reinitialization with Upload first
    '
    repl.ReinitializeSubscription(True)

    ' Synchronize to the SQL Server to populate the Subscription 
    '
    repl.Synchronize()
Catch
    ' Handle errors here
Finally
    ' Dispose the repl object
    '
    repl.Dispose()
End Try
SqlCeReplication repl = null;

try
{
    // Create SqlCeReplication instance
    //
    //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.
    //
    repl = new SqlCeReplication();
    repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa35.dll";
    repl.InternetLogin = "MyInternetLogin";
    repl.InternetPassword = "<enterStrongPassword>";
    repl.Publisher = "MyPublisher";
    repl.PublisherDatabase = "MyPublisherDatabase";
    repl.PublisherLogin = "MyPublisherLogin";
    repl.PublisherPassword = "<enterStrongPassword>";
    repl.Publication = "MyPublication";
    repl.Subscriber = "MySubscriber";
    repl.SubscriberConnectionString = "Data Source=MyDatabase.sdf";

    // Mark the subscription for reinitialization with Upload first
    //
    repl.ReinitializeSubscription(true);

    // Synchronize to the SQL Server to populate the Subscription 
    //
    repl.Synchronize();
}
catch (SqlCeException)
{
    // Handle errors here
}
finally
{
    // Dispose the repl object
    //
    repl.Dispose();
}

関連項目

参照

SqlCeReplication クラス

SqlCeReplication メンバー

System.Data.SqlServerCe 名前空間