SqlCeCommand.CommandType Property

Gets or sets a value indicating how the CommandText property is interpreted.

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

Syntax

'Declaration
Public Overrides Property CommandType As CommandType
    Get
    Set
'Usage
Dim instance As SqlCeCommand
Dim value As CommandType

value = instance.CommandType

instance.CommandType = value
public override CommandType CommandType { get; set; }
public:
virtual property CommandType CommandType {
    CommandType get () override;
    void set (CommandType value) override;
}
abstract CommandType : CommandType with get, set
override CommandType : CommandType with get, set
override function get CommandType () : CommandType
override function set CommandType (value : CommandType)

Property Value

Type: System.Data.CommandType
One of the CommandType values. The default is Text.

Implements

IDbCommand.CommandType

Exceptions

Exception Condition
ArgumentException

The value was not a valid CommandType.

Remarks

SQL Server Compact supports only the Text and TableDirect CommandTypes. An unsupported exception is thrown if StoredProcedure is specified.

TableDirect is the fastest way to retrieve data from SQL Server Compact, but cannot be used with joined tables.

The Connection, CommandType, and CommandText properties cannot be set if the current connection is performing an Execute or Fetch operation.

Examples

The following example creates an instance of SqlCeCommand and sets the CommandType and other properties.

Dim cmd As SqlCeCommand = conn.CreateCommand()
cmd.CommandText = "SELECT * FROM Categories ORDER BY CategoryID"
cmd.CommandType = CommandType.Text
cmd.UpdatedRowSource = UpdateRowSource.Both
SqlCeCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * FROM Categories ORDER BY CategoryID";
cmd.CommandType = CommandType.Text;
cmd.UpdatedRowSource = UpdateRowSource.Both;

See Also

Reference

SqlCeCommand Class

System.Data.SqlServerCe Namespace

CommandText

UpdatedRowSource