SqlCeReplication.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
)
public void ReinitializeSubscription (
    boolean uploadBeforeReinitialize
)
public function ReinitializeSubscription (
    uploadBeforeReinitialize : boolean
)
不适用。

参数

  • uploadBeforeReinitialize
    如果为 True,则订阅数据库中的更改将首先上载给发行者,然后订户才应用快照。默认为 False。

备注

将在 SQL Server Compact Edition 订阅系统表中设置一个标志,指示该订阅将在下次同步过程中重新进行初始化。调用 ReinitializeSubscription 方法后,应用程序必须调用 Synchronize 方法删除现有副本,并将新的发布副本下载到基于 Windows Mobile 的设备上。

示例

Dim repl As SqlCeReplication = Nothing

Try
    ' Create SqlCeReplication instance
    '
    repl = New SqlCeReplication()
    repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa30.dll"
    repl.InternetLogin = "MyInternetLogin"
    repl.InternetPassword = "<password>"
    repl.Publisher = "MyPublisher"
    repl.PublisherDatabase = "MyPublisherDatabase"
    repl.PublisherLogin = "MyPublisherLogin"
    repl.PublisherPassword = "<password>"
    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
    //
    repl = new SqlCeReplication();
    repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa30.dll";
    repl.InternetLogin = "MyInternetLogin";
    repl.InternetPassword = "<password>";
    repl.Publisher = "MyPublisher";
    repl.PublisherDatabase = "MyPublisherDatabase";
    repl.PublisherLogin = "MyPublisherLogin";
    repl.PublisherPassword = "<password>";
    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();
}

平台

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支持 Microsoft .NET Framework 3.0。

版本信息

.NET Framework

受以下版本支持:3.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

SqlCeReplication 类
SqlCeReplication 成员
System.Data.SqlServerCe 命名空间