Installing and Deploying on a Desktop (SQL Server Compact)

SQL Server Compact is available for use on desktop computers without the need for installing Visual Studio 2008 or SQL Server 2008. The SQL Server Compact 3.5 Service Pack 1 (SP1) installer for desktop computers (SSCERuntime-ENU.msi) contains runtime binary files for desktop computers only. The installer contains the following libraries:

  • SQLCESE35.DLL
  • SQLCEQP35.DLL
  • SQLCEME35.DLL
  • SQLCEOLEDB35.DLL (OLEDB data provider)
  • SQLCECA35.DLL
  • SQLCECOMPACT35.DLL
  • SQLCEER35xx.DLL (error messages where xx is the language)
  • System.Data.SqlServerCe.dll (ADO.NET data provider)
  • System.Data.SqlClient.dll
  • System.Data.SqlServerCe.Entity.dll
  • Microsoft.Synchronization.Data.dll
  • Microsoft.Synchronization.Data.Server.dll
  • Microsoft.Synchronization.Data.SqlServerCe.dll

Installation Requirements

Unless you are using the OLEDB data provider, the Microsoft .NET Framework 2.0 or a later version is required to install SQL Server Compact 3.5. You can download the .NET Framework 2.0 from the .NET Framework 2.0 Download Center.

The following software is not required to install SQL Server Compact on desktop computers because this installer has runtime binary files only:

  • Internet Information Services (IIS) 5.x or later versions of IIS (32-bit only)

  • ActiveSync 4.0 or later version

  • Internet Explorer 6.0

  • Neither Visual Studio nor SQL Server is required to install SQL Server Compact on desktop computers.

    Important

    To replicate data between SQL Server and SQL Server Compact, you must install replication components. For more information about SQL Server replication components, see Hardware and Software Requirements. You must also install the server tools (SSCEServerTools-ENU.msi). For more information about the server tools, see Connectivity Tools.

Installation Location

The SQL Server Compact 3.5 and 3.5 SP1 installers for desktop computers install SQL Server Compact in a fixed location. The fixed installation location provides serviceability support for SQL Server Compact. The SQL Server Compact 3.5 Setup program will install the managed assemblies, such as System.Data.SqlServerCe.dll, in the global assembly cache (GAC), and register native DLLs, such as OLE DB Provider (sqlceoledb35.dll), in the registry. Because of the registry installation, SQL Server Compact can only be installed by a user with administrative credentials. SQL Server Compact 3.5 SP1 is installed at the following location:

%ProgramFiles%\Microsoft SQL Server Compact Edition\v3.5

If the Program Files directory is in the C drive, SQL Server Compact 3.5 SP1 runtime binaries will be installed in the C:\Program Files\Microsoft SQL Server Compact Edition\v3.5 directory.

After you install SQL Server Compact 3.5 SP1, you can see the program in Add or Remove Programs as Microsoft SQL Server Compact 3.5 SP1.

DataDirectory Support

DataDirectory is a substitution string that indicates the path of the database. DataDirectory makes it easy to share a project and to deploy an application by eliminating the need to hard-code the full path. For example, instead of having the following connection string:

"Data Source= c:\program files\MyApp\Mydb.sdf"

By using |DataDirectory| (enclosed in pipe symbols as shown), you can have the following connection string:

"Data Source = |DataDirectory|\Mydb.sdf"

You set the DataDirectory property on the AppDomain by calling AppDomain.SetData.

Note

AppDomain.SetData is not supported by the .NET Compact Framework. However, the .NET Compact Framework data provider is required to create applications for mobile devices. Therefore, if DataDirectory property is used when you program applications for mobile devices, SQL Server Compact returns an error.

If you do not set the DataDirectory property, the following default rules will be applied to access the database folder path:

  • For applications that are put in a directory on the client computer, the path of the database will be the folder in which the application is put. For example, if MyApp.exe is put in the /MyDir folder, the /MyDir folder will be accessed.
  • For applications that run under ClickOnce, a data folder is created for that purpose and will be accessed.
  • For Web applications, the App_Data folder will be accessed. You can set DataDirectory to App_Data folder by using AppDomain.SetData.