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();
}