How to: Specify the Location of the Temporary Database by Using ADO.NET (Programmatically)

You can explicitly specify the location and size of the temporary database by using the Microsoft .NET Compact Framework Data Provider for SQL Server Compact 4.0. To do this, add the temp file directory and temp file max size properties to the connection string, as follows:

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

Note

The location you specify for the temporary database must already exist.

Example

The following example shows how to pass the temporary database location in the connection string of the SqlCeConnection object.

SqlCeConnection conn = new SqlCeConnection();
conn.ConnectionString = @"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";
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 = '<enterStrongPasswordHere>'; File Mode = 'shared read';" & _
   "Max Database Size = 256; Max Buffer Size = 1024"
conn.Open()