如何使用 Replication 和 RDA 对象指定临时数据库的位置

通过使用 Microsoft SQL Server 2005 Compact Edition 复制和远程数据访问对象,可以显式指定临时数据库的位置和大小。若要指定位置,请在连接字符串(使用 SqlCeReplication.SubscriberConnectionString 或 SqlCeRemoteDataAccess.LocalConnectionString 设置)中添加 temp path、temp file directory 或 ssce:temp file directory 参数。若要指定大小,请添加 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 = '<password>'; 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 = '<password>'; 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 = '<password>'; 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 = '<password>'; File Mode = 'shared read';" & _
   "Max Database Size = 256; Max Buffer Size = 1024"

请参阅

帮助和信息

获取 SQL Server Compact Edition 帮助