Freigeben über


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
'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;
}
/** @property */
public CommandType get_CommandType ()

/** @property */
public void set_CommandType (CommandType value)
public override function get CommandType () : CommandType

public override function set CommandType (value : CommandType)
Not applicable.

Property Value

One of the CommandType values. The default is Text.

Exceptions

Exception type Condition

ArgumentException

The value was not a valid CommandType.

Remarks

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

TableDirect is the fastest way to retrieve data from SQL Server Compact Edition, 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.

Example

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;

Platforms

Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows XP Professional x64 Edition, Windows XP SP2

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

.NET Compact Framework

Supported in: 2.0, 1.0

See Also

Reference

SqlCeCommand Class
SqlCeCommand Members
System.Data.SqlServerCe Namespace
CommandText
UpdatedRowSource