SQL Server Compact Edition and Visual Studio
This topic is new for Visual Studio 2005 SP1.
SQL Server Compact Edition is nearly identical to the product known as SQL Server Mobile Edition that was previously available for data applications on mobile devices. The only difference is that the limitation for using the product on mobile applications has been removed. In other words, SQL Server Compact Edition is basically the same product as SQL Server Mobile with its license restriction removed. In addition to developing data applications that target mobile devices and Tablet PCs, you can now use SQL Server Compact Edition in applications that will be deployed to the desktop.
SQL Server Compact Edition is not actually installed when you run the Visual Studio installation or upgrade to Visual Studio 2005 SP1. You have to download it from the Microsoft Download Center.
SQL Server Compact Edition is a file-based database that consists of seven DLLs that are approximately 1.4 MB. (Traditional database engines like SQL Server and SQL Server Express run as a service and have a much larger footprint.)
The following list provides some scenarios in which you might want to use SQL Server Compact Edition in your applications:
For applications intended for desktop computers and mobile devices.
For applications that require occasionally connected scenarios.
When you need a database that is free to redistribute.
When footprint and memory requirements must be compact.
When you want the data access code to run in a process.
Installing SQL Server Compact Edition
Design-time support for SQL Server Compact Edition is incorporated into Visual Studio 2005 SP1. However, you have to download and install the actual SQL Server Compact Edition files onto your development computer.
To use SQL Server Compact Edition with Visual Studio, you must install both the SQL Server Compact Edition runtime and the SQL Server Compact Edition Tools for Visual Studio. For detailed instructions, see.
SQL Server Compact Edition provides the following features to consider when you are using it as the local data store for your applications.
File-Based Database Engine
SQL Server Compact Edition is file based, which means that the connection string is a file path to the database (.sdf) file. In addition, the database engine does not run as a service. This is one of the main differences between using SQL Server Compact Edition, and SQL Server or SQL Server Express Edition.
SQL Server Compact Edition (like SQL Server 2005 Mobile) supports multiple connections up to the 256 connection limit. Opening connections on different processes is also supported.
The current version of SQL Server Compact Edition supports database files up to 4 GB.
SQL Server Compact Edition provides two deployment models that you can incorporate into your applications.
You can use the traditional Microsoft setup technology, including ClickOnce deployment. You can also use a file-based deployment in which you add the SQL Server Compact Edition DLLs and deploy them with your project.
Data Directory Support
SQL Server Compact Edition now supports the Data Directory macro. This means that you can add the string |DataDirectory| (enclosed in pipe symbols), and it will resolve to the path of the database.
For example, consider the connection string:
"Data Source= c:\program files\MyApp\Mydb.sdf"
When using Data Directory, you can instead use the following connection string:
"Data Source = |DataDirectory|\Mydb.sdf"
For more information see.
Backward Compatibility with SQL Server Mobile Edition
SQL Server Compact Edition contains the same dlls, namespaces, and types as the originalnamespace, maintaining full backward compatibility with previous applications. The only difference is the removal of the limitation for running on devices.