如何使用 ADO.NET 指定临时数据库的位置(以编程方式)

您可以通过使用 SQL Server 2005 Compact Edition 的 Microsoft .NET Compact Framework 数据访问接口,显式指定临时数据库的位置和大小。若要进行此操作,请将 temp file directory 和 temp file max size 属性添加到连接字符串中,如下所示:

"temp file directory = temp_database_location; temp file max size=128;"

注意:
为临时数据库指定的位置必须已经存在。

示例

下面的示例显示如何将临时数据库位置传递到 SqlCeConnection 对象的连接字符串中:

SqlCeConnection conn = new SqlCeConnection();
conn.ConnectionString = @"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";
conn.Open();
Dim conn As New SqlCeConnection()
conn.ConnectionString = "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"
conn.Open()

请参阅

帮助和信息

获取 SQL Server Compact Edition 帮助