OracleCommand.CommandType Property

Definition

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

public:
 property System::Data::CommandType CommandType { System::Data::CommandType get(); void set(System::Data::CommandType value); };
public:
 virtual property System::Data::CommandType CommandType { System::Data::CommandType get(); void set(System::Data::CommandType value); };
public System.Data.CommandType CommandType { get; set; }
public override System.Data.CommandType CommandType { get; set; }
member this.CommandType : System.Data.CommandType with get, set
Public Property CommandType As CommandType
Public Overrides Property CommandType As CommandType

Property Value

One of the CommandType values. The default is Text.

Implements

Exceptions

The value was not a valid CommandType.

Examples

The following example creates an instance of a derived class OracleCommand and sets some of its properties.

public void CreateOracleCommand()
{
   OracleCommand command = new OracleCommand();
   command.CommandText = "SELECT * FROM Emp ORDER BY EmpNo";
   command.CommandType = CommandType.Text;
}
Public Sub CreateOracleCommand()
    Dim command As New OracleCommand()
    command.CommandText = "SELECT * FROM Emp ORDER BY EmpNo"
    command.CommandType = CommandType.Text
End Sub

Remarks

When the CommandType property is set to StoredProcedure, you should set the CommandText property to the full Oracle call syntax. The command then executes this stored procedure when you call one of the Execute methods (for example, ExecuteReader or ExecuteNonQuery).

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

The .NET Framework Data Provider for Oracle does not support the question mark (?) placeholder for passing parameters to an SQL statement called by an OracleCommand of CommandType.Text. In this case, named parameters must be used. For example:

SELECT * FROM Customers WHERE CustomerID = :pCustomerID  

When using named parameters in an SQL statement called by an OracleCommand of CommandType.Text, you must precede the parameter name with a colon (:). However, in a stored procedure, or when referring to a named parameter elsewhere in your code (for example, when adding OracleParameter objects to the Parameters property), do not precede the named parameter with a colon (:). The .NET Framework Data Provider for Oracle supplies the colon automatically.

Applies to

See also