Executes an SQL statement against the SqlCeConnection and returns the number of rows affected.
Assembly: System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)
The connection does not exist.
The connection is not open.
Cannot execute a command within a transaction context that differs from the context in which the connection was originally enlisted.
You can use to perform catalog operations. For example, you can use it to query the structure of a database or create database objects, such as tables. You also can use to change the data in a database without using a DataSet by executing UPDATE, INSERT, or DELETE statements.
does not use a cursor, and therefore does not place locks on the database. If you are issuing a command that requires a lock, do not use . Instead, use ExecuteReader.
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other DML statements, the return value is -1.
For DDL statements, such as CREATE TABLE or ALTER TABLE, the return value is 0.
This differs from the behavior of System.Data.SqlClient.
The following example creates a SqlCeCommand and then executes it by using . The example is passed a string that is an SQL statement (such as UPDATE, INSERT, or DELETE) and a string for connecting to the data source.