Export (0) Print
Expand All

SqlCeCommand Class

Represents an SQL statement to execute against a data source.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

public ref class SqlCeCommand sealed : public DbCommand, 
	ICloneable

The SqlCeCommand type exposes the following members.

  NameDescription
Public methodSqlCeCommand()Initializes a new instance of the SqlCeCommand class.
Public methodSqlCeCommand(String)Initializes a new instance of the SqlCeCommand class with the text of the query.
Public methodSqlCeCommand(String, SqlCeConnection)Initializes a new instance of the SqlCeCommand class with the text of the query and a SqlCeConnection.
Public methodSqlCeCommand(String, SqlCeConnection, SqlCeTransaction)Initializes a new instance of the SqlCeCommand class with the text of the query, a SqlCeConnection, and the SqlCeTransaction.
Top

  NameDescription
Protected propertyCanRaiseEvents (inherited from Component)
Public propertyCommandTextGets or sets an SQL statement to execute at the data source. (Overrides DbCommand::CommandText.)
Public propertyCommandTimeoutGets or sets the wait time before terminating the attempt to execute a command and generating an error. (Overrides DbCommand::CommandTimeout.)
Public propertyCommandTypeGets or sets a value indicating how the CommandText property is interpreted. (Overrides DbCommand::CommandType.)
Public propertyConnectionGets or sets the SqlCeConnection used by this instance of the SqlCeCommand.
Public propertyContainer (inherited from Component)
Protected propertyDbConnection (inherited from DbCommand)
Protected propertyDbParameterCollection (inherited from DbCommand)
Protected propertyDbTransaction (inherited from DbCommand)
Protected propertyDesignMode (inherited from Component)
Public propertyDesignTimeVisibleGet always returns false; set always throws a NotSupportedException. (Overrides DbCommand::DesignTimeVisible.)
Protected propertyEvents (inherited from Component)
Public propertyIndexNameSpecifies the index to be opened.
Public propertyParametersGets the SqlCeParameterCollection.
Public propertySite (inherited from Component)
Public propertyTransactionGets or sets the transaction in which the SqlCeCommand executes.
Public propertyUpdatedRowSourceGets or sets how command results are applied to the DataRow when used by the Update method of the DbDataAdapter. This property should not be used with the .NET Compact Framework Data Provider for SQL Server Compact. (Overrides DbCommand::UpdatedRowSource.)
Top

  NameDescription
Public methodCancelAttempts to cancel the execution of a SqlCeCommand. (Overrides DbCommand::Cancel().)
Protected methodCreateDbParameter (inherited from DbCommand)
Public methodCreateObjRef (inherited from MarshalByRefObject)
Public methodCreateParameterCreates a new instance of a SqlCeParameter object.
Public methodDispose() (inherited from Component)
Protected methodDispose(Boolean) (inherited from Component)
Public methodEquals (inherited from Object)
Protected methodExecuteDbDataReader (inherited from DbCommand)
Public methodExecuteNonQueryExecutes an SQL statement against the SqlCeConnection and returns the number of rows affected. (Overrides DbCommand::ExecuteNonQuery().)
Public methodExecuteReader()Sends the CommandText to the Connection and builds a SqlCeDataReader.
Public methodExecuteReader(CommandBehavior)Sends the CommandText to the Connection and builds a SqlCeDataReader by using one of the CommandBehavior values.
Public methodExecuteResultSet(ResultSetOptions)Sends the CommandText to the Connection and builds a SqlCeResultSet by using the ResultSetOptions.
Public methodExecuteResultSet(ResultSetOptions, SqlCeResultSet)Sends the CommandText to the Connection and builds a SqlCeResultSet by using the ResultSetOptions.
Public methodExecuteScalarExecutes the query and returns the first column of the first row in the result set that is returned by the query. Extra columns or rows are ignored. (Overrides DbCommand::ExecuteScalar().)
Protected methodFinalize (inherited from Component)
Public methodGetHashCode (inherited from Object)
Public methodGetLifetimeService (inherited from MarshalByRefObject)
Protected methodGetService (inherited from Component)
Public methodGetType (inherited from Object)
Public methodInitializeLifetimeService (inherited from MarshalByRefObject)
Protected methodMemberwiseClone() (inherited from Object)
Protected methodMemberwiseClone(Boolean) (inherited from MarshalByRefObject)
Public methodPrepareCreates a prepared (or compiled) version of the command on the data source. (Overrides DbCommand::Prepare().)
Public methodSetRangeRestricts the set of rows that will be read by the SqlCeDataReader.
Public methodToString (inherited from Component)
Top

  NameDescription
Public eventDisposed (inherited from Component)
Top

  NameDescription
Explicit interface implemetationPrivate methodICloneable::Clone
Explicit interface implemetationPrivate propertyIDbCommand::Connection (inherited from DbCommand)
Explicit interface implemetationPrivate methodIDbCommand::CreateParameter (inherited from DbCommand)
Explicit interface implemetationPrivate methodIDbCommand::ExecuteReader() (inherited from DbCommand)
Explicit interface implemetationPrivate methodIDbCommand::ExecuteReader(CommandBehavior) (inherited from DbCommand)
Explicit interface implemetationPrivate propertyIDbCommand::Parameters (inherited from DbCommand)
Explicit interface implemetationPrivate propertyIDbCommand::Transaction (inherited from DbCommand)
Top

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.

ExecuteResultSet

Executes commands and returns a result set.

The Data Provider for SQL Server Compact does not support batched queries. Commands must be in the following form:

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.

SQL Server Compact supports multiple simultaneous connections as well as multiple commands sharing 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.

The following example uses SqlCeCommand, along with SqlCeConnection, to select rows from a database.

No code example is currently available or this language may not be supported.

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