Jaa


Managed Data Provider (SQL Server Compact Edition)

The System.Data.SqlServerCe namespace provides programmatic access to Microsoft SQL Server 2005 Compact Edition (SQL Server Compact Edition) databases from a managed application. System.Data.SqlServerCe provides a set of classes designed to reveal the functionality of SQL Server Compact Edition. For a list of classes in this namespace, see System.Data.SqlServerCe Namespace Overview.

Supported Functionality

The System.Data.SqlServerCe namespace provides the following functionality:

  • Consistent access to SQL Server Compact Edition data sources.
    Consumer applications that share data can use the SQL Server Compact Edition data provider to connect to SQL Server Compact Edition data sources and then retrieve, work with, and update data.
  • Components for connecting to a database, executing commands, and retrieving results.
    The retrieved results can be processed directly or put in an ADO.NET DataSet or ResultSet object to be revealed to the user, combined with data from multiple sources, or propagated remotely between tiers.
  • Functionality to developers writing managed code.
    This functionality is similar to that provided by ADO to native COM developers.
  • Index functionality for optimal performance.
    SqlCeCommand.SetRange restricts the set of row entries visible through calls to SqlCeDataReader.Read and SqlCeDataReader.Seek. SqlCeDataReader.Seek permits direct positioning at a key value within the current range.
  • Interfaces needed to interact with the SQL Server Compact Edition Replication and Remote Data Access (RDA) objects through the SqlCeReplication and SqlCeRemoteDataAccess classes.
  • SqlCeEngine class methods that enable database creation and compaction.
  • Database encryption and password protection.

Provider Limitations

The data provider for SQL Server Compact Edition has the following limitations:

  • No support for batch queries. Queries must be a single SQL statement. For example, the following statement is valid:

    SELECT * FROM Customers
    

    This statement is not valid:

    SELECT * FROM Customers; SELECT * FROM Customers2
    

    Datasets must be refreshed from a SqlCeDataAdapter. If you are using code from a Visual Studio 2005 project, you must modify your SQL statement to comply with this restriction.

  • There is no support for nested transactions, but parallel transactions are supported.

  • SQL Server Compact Edition is not currently optimized to serve as a database for Web sites. By default, connections from ASP.NET-connected applications are blocked in SQL Server Compact Edition. SQL Server Compact Edition is optimized for use as an embedded database within applications. Using SQL Server Compact Edition as a database for Web sites requires support for multiple users and concurrent data changes. This can cause performance problems. Therefore, these scenarios are not supported. Other editions of SQL Server 2005, including SQL Server 2005 Express Edition, are optimized to serve as a database for Web sites. SQL Server Compact Edition can be used with ASP.NET in application scenarios where ASP.NET is used to create SQL Server Compact Edition databases for synchronization. Use the following code to change the default behavior of SQL Server Compact Edition to work within ASP.NET.

    AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true)
    

See Also

Reference

System.Data.SqlServerCe Namespace Overview
System.Data.SqlServerCe Namespace (.NET Framework Reference Documentation)

Other Resources

Building Managed Applications (SQL Server Compact Edition)
Managed Programming How Tos (SQL Server Compact Edition)

Help and Information

Getting SQL Server Compact Edition Assistance