You can develop applications that use SQL Server Compact 3.5 by using the Microsoft Visual Studio development environment. Visual Studio is the easiest way to develop and deploy an application that uses SQL Server Compact 3.5. In Visual Studio, you can create a managed application by using Visual C# or Visual Basic. You can also create a native application for desktop computers and devices by using Visual C++ option (previously known as Microsoft eMbedded Visual C++ 4.0). Visual C++ is supported in Visual Studio 2008 and later versions.

Microsoft eMbedded Visual Basic is not supported by SQL Server Compact 3.5 or later versions.

You can use Visual Studio 2008 and later versions to develop applications for SQL Server Compact 3.5; however,

  • Visual Studio 2010 is preferred for developing desktop applications. This is because Visual Studio 2010 supports new development features, such as support for the Transact-SQL editor on SQL Server Compact databases. You can use Visual Studio 2008 or Visual Studio 2008 Service Pack 1 (SP1) to develop desktop applications for SQL Server Compact 3.5, but the new development features provided in Visual Studio 2010 will not be available to you.

  • Visual Studio 2008 Service Pack 1 (SP1) is preferred for developing device applications. This is because Visual Studio 2010 does not provide support for developing smart device applications.

Visual Studio 2010 and Visual Studio 2008 SP1 can be installed and run side-by-side on the same computer.

Visual Studio File Locations and Descriptions

The following table lists the SQL Server Compact 3.5 files, by location, that are installed on the development computer when you use Visual Studio 2008 or Visual Studio 2010. By default, these files and folders are created in:

  • %ProgramFiles%\Microsoft Visual Studio 9.0 for Visual Studio 2008.

  • %ProgramFiles%\Microsoft Visual Studio 10.0 for Visual Studio 2010.

  • %ProgramFiles%\Microsoft SQL Server Compact Edition\v3.5\ for SQL Server Compact 3.5.

Location

Contents

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

SQL Server Compact 3.5 DLLs for desktop computers: sqlcecompact35.dll, sqlceca35.dll, sqlceme35.dll, sqlceoledb35.dll, sqlceqp35.dll, and sqlcese35.dll. The error descriptions DLL, sqlceer35<lang>.dll, is also installed in the folder. The error DLL for the different languages contains a two-letter suffix that indicates the language: EN, FR, and so on. The folder also contains Read Me, Licensing Terms, and Redist_<lang>.txt. The folder also contains the Managed Provider for SQL Server Compact 3.5 Entity Framework: System.Data.SqlServerCe.Entity.dll. This is the version installed in the Global Assembly Cache (GAC). Use this version of the entity framework provider when building desktop applications for which SQL Server Compact is centrally deployed; or when building device applications. Starting with SQL Server Compact 3.5 SP2, for desktop applications that privately deploy SQL Server Compact use the version of the provider in %ProgramFiles%\Microsoft SQL Server Compact Edition\v3.5\Private.

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

Managed Provider for SQL Server Compact 3.5 for Desktop: System.Data.SqlServerCe.dll. Starting with SQL Server Compact 3.5 SP2, this folder contains the version of the managed provider to use when building desktop applications that use central deployment of SQL Server Compact. This is the version installed in the GAC. Starting with SQL Server Compact 3.5 SP2, for desktop applications that privately deploy SQL Server Compact use the version of the provider in %ProgramFiles%\Microsoft SQL Server Compact Edition\v3.5\Private.

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

Managed Provider for SQL Server Compact 3.5 for Desktop, System.Data.SqlServerCe.dll; and Managed Provider for SQL Server Compact 3.5 Entity Framework, System.Data.SqlServerCe.Entity.dll. This folder is introduced with SQL Server Compact 3.5 SP2. It contains the version of these providers to use when building desktop applications that use private deployment of SQL Server Compact.

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

Managed Provider for SQL Server Compact 3.5 for Devices: System.Data.SqlServerCe.dll. This folder contains the version of the managed provider to use when building a device application. This version of the managed provider is used regardless of whether SQL Server Compact is centrally or privately deployed on a device. 

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

SQL Server Compact 3.5 Server Tools DLLs for replicating data between SQL Server and SQL Server Compact 3.5: sqlcesa35.dll, sqlcerp35.dll, and ConnWiz.exe. The folder also contains the file that has the SQL Server Compact 3.5 Server Tools license terms.

%ProgramFiles%\Microsoft SQL Server Compact Edition\v3.5\<lang>

Localized resources for the managed provider: System.Data.SqlServerCe.resources.dll

%ProgramFiles%\Microsoft SQL Server Compact Edition\v3.5\Devices\platform\processor

Series of subfolders. Each folder contains:

sqlce.platform.processor.cab

The sqlce.platform.processor.cab file contains sqlcese35.dll, sqlceqp35.dll, sqlceme35.dll, System.Data.SqlServerCe.dll.

sqlce.repl. platform.processor.cab

The sqlce.repl.platform.processor.cab file contains sqlceca35.dll, sqlceoledb35.dll, and sqlcecompact35.dll.

sqlce.dev.lang.platform.processor.cab The sqlce.dev.lang.platform.processor.cab file contains isqlw35.exe, a program that implements SQL Server Compact 3.5 Query Analyzer, and sqlceerr35lang.dll that provides error descriptions for use during development.

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

System.Data.SqlClient.dll that is used for directly connecting to the SQL Server from a mobile device without using SQL Server Compact 3.5. The CAB files for deploying SQL Server Compact 3.5 on mobile devices are sql.[platform].[processor].cab and sql.dev.[platform].[processor].cab. The CAB files are available under %ProgramFiles%\Microsoft SQL Server Compact Edition\v3.5\Devicesplatform\processor.

The CAB files and DLL files under the folder %ProgramFiles%\Microsoft SQL Server Compact Edition\v3.5\Devices\wce500 are also used to install SQL Server Compact 3.5 on Windows CE 6.0 and Windows Mobile 6.0 devices.

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

SQL Server Compact 3.5 native header files (sqlce_sync.h, sqlce_err.h, and sqlce_oledb.h).

%ProgramFiles%\Microsoft Visual Studio 9.0\SDK\v3.5\Bootstrapper\Packages\SQL Server Compact Edition\

-or-

%ProgramFiles%\Microsoft Visual Studio 10.0\SDK\v3.5\Bootstrapper\Packages\SQL Server Compact Edition\

Series of folders that contain the SQL Server Compact 3.5 files for deploying SQL Server Compact 3.5 on desktop computers by using the ClickOnce feature of Visual Studio.

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

Contains the sample database, Northwind.sdf. It also contains the NorthwindOLEDB and the IBuySpy sample that is installed by the SQL Server Compact 3.5 SP1 Samples MSI.

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

Contains the DLLs that are used in SQL Server Management Studio for administering a SQL Server Compact database. The DLLs are installed by the SQL Server Compact 3.5 Query Tools MSI.

The files are:

Microsoft.SqlServerCe.Client.dll, Microsoft.SqlServerCe.Enumerator.dll, Microsoft.SqlServerCe.ManagementUI.dll, Microsoft.SqlServerCe.ReplWiz.dll, and ConnWiz.exe.

%ProgramFiles%\Microsoft Synchronization Services\ADO.NET\v1.0\

The DLLs for Sync Services for ADO.NET are:

Microsoft.Synchronization.Data.Server.dll, Microsoft.Synchronization.Data.dll, Microsoft.Synchronization.Data.SqlServerCe.dll, and ReadMeSSC35.htm.

For information about 64-bit components, see Managing 64-bit Database Applications.

Managed Application Development

For Device applications, in the Microsoft .NET Compact Framework application, add a reference to the System.Data.SqlServerCe namespace. The System.Data.SqlServerCe namespace exposes SQL Server Compact 3.5 in the .NET Compact Framework. You can then create a database, database tables, and columns, and add data to the database. For more information about building a managed application that uses SQL Server Compact 3.5 for a smart device, see Building Smart Device Applications (SQL Server Compact).

When you build the application and deploy it to a smart device or the Pocket PC emulator from Visual Studio, Visual Studio automatically checks to see whether the device has the .NET Compact Framework and SQL Server Compact 3.5 client components installed. If these components are not detected, they are automatically installed on the device the first time that you deploy any application built with SQL Server Compact 3.5 from Visual Studio. 

To deploy a managed application to a mobile device from Visual Studio, select Start Debugging from the Debug menu. Then, decide whether you want to deploy to a connected smart device or to the Pocket PC emulator. The default installation location on the device is %ProgramFiles%\Microsoft SQL Server Compact Edition\v3.5.

For desktop applications, in the Microsoft .NET Framework application, add a reference to the System.Data.SqlServerCe namespace. The System.Data.SqlServerCe namespace exposes SQL Server Compact 3.5 in the .NET Framework. You can then create a database, database tables, and columns, and add data to the database. How you add the reference to System.Data.SqlServerCe namespace depends on whether you are building your application for private deployment or for central deployment of SQL Server Compact 3.5.

  • If you are building your application to use the centrally deployed version of SQL Server Compact 3.5 on the target computer, add the reference from the .NET tab of the Add Reference dialog box.

  • If you are building your application to use a version of SQL Server Compact 3.5 deployed privately with the application, click the Browse tab in the Add Reference dialog box and browse to the %ProgramFiles%\Microsoft SQL Server Compact Edition\v3.5\Private folder to add the reference. 

For more information about building a managed application that uses SQL Server Compact 3.5 for the desktop, see Building Applications for Desktops (SQL Server Compact)

To deploy a managed application to the desktop from Visual Studio, select Start Debugging from the Debug menu. SQL Server Compact 3.5 is installed with Visual Studio, so there is no need to install it on the development computer before deploying the application.

The .NET Compact Framework and the .NET Framework also include the System.Data.SqlClient namespace for developing applications that directly access databases in SQL Server 2005 or later versions.

ClickOnce Deployment for Deploying Managed Applications

ClickOnce is a new software installation technology that is supported by SQL Server Compact 3.5 for deploying managed applications on desktop computers. ClickOnce simplifies deploying a Windows-based application to a Web server or network file share. For administrators, deploying or updating an application consists of updating files on a server. You do not have to update each client individually. Visual Studio 2008 provides full support for publishing and updating applications that are deployed with ClickOnce. ClickOnce deployment is available for projects that are created by using Visual Basic, Visual C#, and Visual J#, but not for Visual C++.

Native Device Application Development with Visual C++

Visual C++ is an option available in Visual Studio that you can use to develop native applications that use SQL Server Compact 3.5.

When you develop a SQL Server Compact 3.5 application by using Visual C++, create a blank Visual C++ project and include SQL Server Compact 3.5 in the project. To do this, on the Project menu, click Add Files, and then add sqlce_sync.h, sqlce_err.h, and sqlce_oledb.h to your project.

When you develop native applications by using Visual C++, you must manually copy SQL Server Compact 3.5 to the smart device. For more information, see Installing and Deploying on a Device (SQL Server Compact). SQL Server Compact 3.5 can be deployed on desktop computers by the SQL Server Compact 3.5 installer (SSCERuntime-ENU.msi).

Tasks

How to: Install SQL Server Compact on a Device

Reference

Deploying Applications (SQL Server Compact)

Concepts

Building Native Applications (SQL Server Compact)

Other Resources

Building Managed Applications (SQL Server Compact)