Share via


SqlCeCommand Class

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Represents an SQL statement to execute against a data source.

For a list of all members of this type, see SqlCeCommand Members.

System.Object
   System.MarshalByRefObject
      System.Data.SqlServerCe.SqlCeCommand

  [Visual Basic]
  NotInheritable Public Class SqlCeCommand
   Inherits MarshalByRefObject
   Implements ICloneable, IDbCommand, IDisposable

  [C#]
  public sealed class SqlCeCommand : MarshalByRefObject, ICloneable,
   IDbCommand, IDisposable

  [C++]
  public __gc __sealed class SqlCeCommand : public
   MarshalByRefObject, ICloneable, IDbCommand, IDisposable

  [JScript]
  public class SqlCeCommand extends MarshalByRefObject implements
   ICloneable, IDbCommand, IDisposable

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

When an instance of SqlCeCommand is created, the read/write properties are set to their initial values. For a list of these values, see the SqlCeCommand constructor.

SqlCeCommand features the following methods that execute commands at a data source:

Item Description
ExecuteReader Executes commands that return rows.
ExecuteNonQuery Executes SQL commands such as INSERT, DELETE, and UPDATE statements.
ExecuteScalar Retrieves a single value (for example, an aggregate value) from a database.

The .NET Compact Framework data provider for SQL Server CE does not support named parameters for passing parameters to an SQL statement called by a SqlCeCommand when CommandType is set to Text. You must use the question mark (?) placeholder. For example:

SELECT * FROM Customers WHERE CustomerID = ?

The order in which you add SqlCeParameter objects to the SqlCeParameterCollection must correspond to the position of the question mark placeholder for the parameter.

The data provider for SQL Server CE also does not support batched queries. Commands must be in the form of Select * from Customers and not Select * from Customers; Select *

from Orders;. If you are using code generated for System.Data.SqlClient, you may have to alter your queries to conform to this restriction.

Although SQL Server CE only supports one connection at a time, multiple commands can share the same connection. This means that it is possible to have multiple instances of SqlCeDataReader on the same connection. This behavior differs from that of System.Data.SqlClient.

If a fatal SqlCeException is generated by the method executing a SqlCeCommand, the SqlCeConnection may be closed. You can reopen the connection and continue.

Requirements

Namespace: System.Data.SqlServerCe

Platforms: .NET Compact Framework

Assembly: System.Data.Sqlserverce (in System.Data.Sqlserverce.dll)

See Also

SqlCeCommand Members | System.Data.SqlServerCe Namespace | SqlCeDataAdapter | SqlCeConnection

Syntax based on .NET Framework version 1.1.
Documentation version 1.1.1.

Send comments on this topic.

© Microsoft Corporation. All rights reserved.