What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use SQL Server CE, install the runtime version your application requires—Compact 3.5 or 4.0—along with provider and native components that match its version and processor architecture. You also need the database file, usually with an .sdf extension, and a connection string that identifies it with Data Source. Both versions are out of Microsoft support, so this is primarily guidance for maintaining legacy applications.

What SQL Server CE is—and what you need

SQL Server Compact, also called SQL Server CE, is an embedded, file-based database engine. It does not run as a separate server service: an application uses the SQL Server Compact provider to work with a database file. Microsoft describes Compact 4.0 as a free embedded database for ASP.NET websites and Windows desktop applications (Microsoft SQL Server Compact 4.0 SP1 download).

For a desktop Windows application, gather these items before connecting:

  • The Compact version expected by the application: 3.5 or 4.0.
  • The corresponding runtime installer and the required x86 or x64 components.
  • The ADO.NET provider, typically System.Data.SqlServerCe, matching the native runtime binaries.
  • The database file, commonly an .sdf file, and access to its folder. The folder must be writable if the application opens the database in the default Read Write mode.

The Microsoft 4.0 SP1 download page provides an x86 installer. Check the application’s requirements for the full runtime and architecture combination it needs; do not infer that installing one package covers every application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the version the application expects

Compact 3.5 and 4.0 are separate legacy branches. Check the project’s provider reference, application documentation, or deployment package before installing or replacing a runtime. A 4.0 runtime should not be assumed to satisfy a 3.5 dependency: verify compatibility with the application and its database before making a change.

Version Microsoft support status What to check before using it
SQL Server Compact 3.5 Extended support ended April 11, 2018; Microsoft marks support as ended (Microsoft lifecycle record). Confirm that the application and database require the 3.5 provider and runtime. For 64-bit Windows deployments, keep the managed provider and native binaries aligned; see the architecture guidance below.
SQL Server Compact 4.0 Mainstream support ended July 13, 2016, and extended support ended July 14, 2021 (Microsoft lifecycle record). Confirm that the application expects 4.0 and that its provider and runtime architecture match. The official 4.0 SP1 page describes the product as an embedded database and provides an x86 installer.

Neither version is currently supported by Microsoft. If you maintain an application that depends on Compact, treat it as a legacy component and assess its longer-term replacement separately; a runtime change alone does not establish that the application or its database will work with another version.

Match the provider, runtime, and processor architecture

The application’s process architecture determines which components it can load. A 32-bit application needs x86 components; a 64-bit application needs x64 components. On a 64-bit Windows machine where both application architectures must be supported, Microsoft says the x86 and amd64 MSIs should be the same version (Microsoft SQL Server Compact 3.5 SP2 desktop deployment guidance).

Keep the managed provider assembly, System.Data.SqlServerCe.dll, and native Compact DLLs compatible in both version and architecture. A mismatch can cause provider or DLL load failures, including Unable to load DLL 'sqlceme35.dll'. That particular DLL name points to a 3.5 component, so first verify that the application is intended to use 3.5 rather than installing a different version by guesswork.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Connect to an .sdf database

Use SqlCeConnection and set its connection string to the database file. Microsoft documents the Data Source value as the file path and name; the connection string is the string used to open the database (Microsoft SqlCeConnection.ConnectionString documentation).

For a desktop application, a path relative to its data directory can be written as:

Data Source=|DataDirectory|MyDb.sdf;

Or specify an absolute path:

Data Source=C:AppsMyAppDataMyDb.sdf;

|DataDirectory| is supported for desktop applications to resolve a location relative to the application data directory. Microsoft notes that this substitution is not supported on devices. Use a path that exists on the target system, and ensure the application has the file permissions needed for its selected access mode.

Choose a database access mode

If you omit the mode, SQL Server Compact uses Read Write by default. Microsoft documents these modes:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Read Write: Opens the database for reading and writing; multiple processes can open and modify it.
  • Read Only: Opens a read-only copy.
  • Exclusive: Prevents other processes from opening or modifying the database.
  • Shared Read: Allows other processes to read while preventing modification.

If the database is password-protected, supply its password in the connection string. Microsoft documents a database-password limit of up to 40 characters and notes that specifying a password enables encryption. Without the correct password, the application cannot open the protected file.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common SQL Server CE errors

  • Provider or DLL load error: Check that the provider assembly and native Compact DLLs are from compatible versions, and that their architecture matches the application.
  • Unable to load DLL 'sqlceme35.dll': Confirm the application’s Compact version, then check its 3.5 native files and architecture. On 64-bit Windows, Microsoft identifies mismatched x86 and amd64 installations as a cause of version-mismatch and DLL-load errors.
  • Database will not open: Verify the full .sdf path, the file and folder permissions, and whether another process has opened the database in Exclusive mode.
  • Password-protected database will not open: Check that the connection string supplies the correct database password.
  • Failure after changing runtime versions: Reconfirm the provider version expected by the application. Do not assume that a 3.5 dependency is satisfied by 4.0 or vice versa.

For Windows CE and Windows Mobile devices

Device deployments have different prerequisites from desktop Windows. Microsoft’s SQL Server Compact 3.5 SP2 device package lists Windows CE 4.2, CE 5.0, CE 6.0, Windows Mobile 2003 Pocket PC, and Windows Mobile 5.0, 6.0, and 6.5 variants. It also lists ActiveSync, certain Visual Studio versions for designer or code scenarios, and the .NET Compact Framework for managed applications. The package gives an approximate storage requirement of 2–3 MB, depending on processor, operating-system version, and installed components (Microsoft SQL Server Compact 3.5 SP2 for Windows Mobile).

These are package-specific legacy targets, not a general statement that Compact works on every current mobile or Windows device. Check the device model, operating-system version, processor target, and application’s deployment requirements before installing.

Inspecting an existing .sdf file

SQLCeToolbox is a community tool that can help inspect or manage SQL Server Compact database files. Its Visual Studio and SQL Server Management Studio compatibility can change, so check the tool’s documentation for current requirements before choosing an installation path (SQLCeToolbox documentation).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.