You can develop device applications using the .NET Compact Framework that access databases in SQL Server version 7.0 or later versions by using the System.Data.SqlClient namespace. System.Data.SqlClient is the namespace of the .NET Compact Framework Data Provider for SQL Server. This data provider corresponds to the System.Data.SqlClient namespace of the Microsoft .NET Framework.

When developing desktop applications, you must use the .NET Framework Data Provider for SQL Server.

Like its counterpart in the .NET Framework, System.Data.SqlClient in the .NET Compact Framework is a collection of classes that can be used to access SQL Server databases with managed code from Windows CE .NET-based devices. 

Unless otherwise noted, all objects in the System.Data.SqlClient namespace match the corresponding objects in the System.Data.SqlClient namespace in the .NET Framework. For more information about the classes in this namespace, see the .NET Compact Framework SDK in Microsoft Visual Studio 2008.

Provider Limitations

The following lists limitations and exceptions that apply to Windows CE .NET-based devices and the .NET Compact Framework:

  • Unsupported classes

    SqlClientPermission and SqlClientPermissionAttribute classes are not supported.

  • ConnectionString property

    The following ConnectionString properties are not supported:

    • AttachDBFilename

    • Max Pool Size

    • Min Pool Size

    • Connection Lifetime

    • Connection Reset

    • Enlist

    • Pooling

    • Network Library

    • Encrypt

    Applications using System.Data.SqlClient on smart devices can use the Windows Authentication protocol instead of using SQL Server Authentication. To do this, the connection string must include the following properties:

    Property

    Value

    Integrated Security

    SSPI

    User ID

    Domain\username

    Password

    <password>

  • ANSI data

    ANSI data is supported only for SQL_Latin1_General_CP1_CI_AS collations from an English-based device. All strings in the .NET Framework are Unicode. System.Data.SqlClient converts ANSI data in SQL Server to Unicode using the .NET Framework Encoding classes. Although the Encoding classes are supported in the .NET Compact Framework, not all code pages are.

    Also, System.Data.SqlClient cannot read from or write to an ANSI column if the code page for the column is not available on the Windows CE-based device. System.Data.SqlClient generates an error when the code page for an ANSI-to-Unicode conversion is not available.

    For information about code pages that are available to a specific smart device, contact the device manufacturer.

  • Connection pooling

    Connection pooling is not supported. A device can only have a small number of connections to an instance of SQL Server at any time.

  • Distributed transactions

    Distributed transactions are not supported. Transactions cannot span databases or servers. System.Data.SqlClient generates an InvalidOperationException exception during a distributed transaction.

  • Net-Library selection

    Only TCP/IP connections to an instance of SQL Server are supported. System.Data.SqlClient cannot connect to SQL Server through a device cradle.

  • Net-Library encryptions

    Encrypted connections to an instance of SQL Server are not supported. If the computer that is running SQL Server has a Secure Sockets Layer (SSL) certificate installed, the connection will fail.

  • Windows Authentication

    Windows Authentication is supported. However, the user ID and password used for authentication within the Domain Controller must always be specified in the connection string.

For more information, see the System.Data.SqlClient namespace reference in the .NET Compact Framework SDK in Microsoft Visual Studio 2008.

Reference

System.Data.SqlServerCe