如何:使用複寫及 RDA 物件來指定暫存資料庫的位置
您可以使用 MicrosoftSQL Server Compact 3.5 複寫及遠端資料存取物件,明確指定暫存資料庫的位置及大小。若要指定位置,請將 temp path、temp file directory 或 ssce:temp file directory 參數加入連接字串 (以 SqlCeReplication.SubscriberConnectionString 或 SqlCeRemoteDataAccess.LocalConnectionString 設定)。若要指定大小,請加入 temp file max size 參數。
注意
指定的暫存資料庫位置必須是已經存在。
範例
下列範例顯示如何使用 Replication 物件內的 SubscriberConnectionString 屬性,來設定暫存資料庫的位置。
SqlCeReplication ceRepl = new SqlCeReplication();
ceRepl.SubscriberConnectionString = @"Persist Security Info = False;
Temp File Directory = '\TempDB\'; Temp File Max Size = 256;
Data Source = 'SalesData.sdf';
Password = '<enterStrongPasswordHere>'; File Mode = 'shared read';
Max Database Size = 256; Max Buffer Size = 1024";
Dim repl As New SqlCeReplication()
repl.SubscriberConnectionString = "Persist Security Info = False;" & _
"Temp File Directory = '\TempDB\'; Temp File Max Size = 256;" & _
"Data Source = 'SalesData.sdf';" & _
"Password = '<enterStrongPasswordHere>'; File Mode = 'shared read';" & _
"Max Database Size = 256; Max Buffer Size = 1024"
下列範例顯示如何使用 RemoteDataAccess 物件內的 LocalConnectionString 屬性,來設定暫存資料庫的位置。
SqlCeRemoteDataAccess rda = new SqlCeRemoteDataAccess();
rda.LocalConnectionString = @"Persist Security Info = False;
Temp Path = '\TempDB\'; Data Source = 'SalesData.sdf';
Password = '<enterStrongPasswordHere>'; File Mode = 'shared read';
Max Database Size = 256; Max Buffer Size = 1024";
Dim rda As New SqlCeRemoteDataAccess()
rda.LocalConnectionString = "Persist Security Info = False;" & _
"Temp Path = '\TempDB\'; Data Source = 'SalesData.sdf';" & _
"Password = '<enterStrongPasswordHere>'; File Mode = 'shared read';" & _
"Max Database Size = 256; Max Buffer Size = 1024"