Installing and Deploying on a Desktop (SQL Server Compact)
Use the SQL Server Compact 4.0 installer for desktop computers (SSCERuntime-ENU.msi) to install SQL Server Compact 4.0. This installer is available as a download. The SQL Server Compact 4.0 installer for desktop computers contains runtime binary files for desktop computers only.
The installer contains the following libraries:
SQLCEOLEDB40.DLL (OLEDB data provider)
SQLCEER40xx.DLL (error messages where xx is the language)
System.Data.SqlServerCe.dll (ADO.NET data provider)
msvcr90.dll (amd 64)
Unless you are using the OLEDB data provider, the Microsoft .NET Framework 4 or a later version is required to install SQL Server Compact 4.0. You can download the .NET Framework 4 from the .NET Framework 4 Download Center.
The following software is not required to install SQL Server Compact on desktop computers because this installer has runtime binary files only:
- Neither Visual Studio nor SQL Server is required to install SQL Server Compact on desktop computers.
The SQL Server Compact 4.0 installer for desktop computers installs SQL Server Compact in a fixed location. The fixed installation location provides serviceability support for SQL Server Compact. The SQL Server Compact 4.0 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 (sqlceoledb40.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 4.0 is installed at the following location: %ProgramFiles%\Microsoft SQL Server Compact Edition\v4.0. For example, if the Program Files directory is in the C drive, SQL Server Compact 4.0 runtime binaries will be installed in the C:\Program Files\Microsoft SQL Server Compact Edition\v4.0 directory.
After you install SQL Server Compact 4.0, you can see the program in Add or Remove Programs as Microsoft SQL Server Compact 4.0.
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.
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.