Managed Data Provider (SQL Server Compact)

The System.Data.SqlServerCe namespace provides programmatic access to Microsoft SQL Server Compact databases from a managed application. System.Data.SqlServerCe provides a set of classes designed to expose the functionality of SQL Server Compact. For a list of classes in this namespace, see System.Data.SqlServerCe.

Supported Functionality

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

  • Consistent access to SQL Server Compact data sources.

    Consumer applications that share data can use the SQL Server Compact data provider to connect to SQL Server Compact 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.

  • SqlCeEngine class methods that enable database creation and compaction.

  • Database encryption and password protection.

Provider Limitations

The data provider for SQL Server Compact 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 project, you must modify your SQL statement to comply with this restriction.

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

See Also

Other Resources

Building Managed Applications (SQL Server Compact)

Managed Programming How Tos (SQL Server Compact)