Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)
'Declaration Public NotInheritable Class SqlCeCommand Inherits DbCommand Implements ICloneable 'Usage Dim instance As SqlCeCommand
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:
Executes commands that return rows.
Executes SQL commands such as INSERT, DELETE, and UPDATE statements.
Retrieves a single value (for example, an aggregate value) from a database.
Executes commands and returns a result set.
The Data Provider for SQL Server Mobile 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 Mobile 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.
The following example uses SqlCeCommand, along with SqlCeConnection, to select rows from a database.
Dim query As String = "SELECT [Order ID], [Customer] FROM Orders" Dim conn As New SqlCeConnection(connString) Dim cmd As New SqlCeCommand(query, conn) conn.Open() Dim rdr As SqlCeDataReader = cmd.ExecuteReader() Try ' Iterate through the results ' While rdr.Read() Dim val1 As Integer = rdr.GetInt32(0) Dim val2 As String = rdr.GetString(1) End While Finally ' Always call Close when done reading ' rdr.Close() ' Always call Close when done reading ' conn.Close() End Try
Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows XP Professional x64 Edition, Windows XP SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.