SqlCeReplication.ReinitializeSubscription Method
標記訂閱以重新初始化。呼叫這個方法之後,應用程式必須呼叫 Synchronize 方法,將發行物的最新快照下載到裝置。
命名空間: System.Data.SqlServerCe
組件: System.Data.SqlServerCe (在 system.data.sqlserverce.dll)
語法
'宣告
Public Sub ReinitializeSubscription ( _
uploadBeforeReinitialize As Boolean _
)
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 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();
}
執行緒安全性
任何公用靜態 (共用 在 Microsoft Visual Basic) 此型別的成員具備執行緒安全。不保證任何執行個體成員安全執行緒。
平台
開發平台
Windows Vista, Windows Mobile 5.0, Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Mobile 2003 for Pocket PC, Windows CE 5.0
版本資訊
.NET Framework 及 NET Compact Framework
支援於 3.5
.NET Framework
支援於 3.0
.NET Compact Framework 及 .Net Framework
支援於 2.0
另請參閱
參考
SqlCeReplication Class
SqlCeReplication Members
System.Data.SqlServerCe Namespace