DB2Command.CommandType Property
Gets or sets a value indicating how the CommandText property is interpreted.
- Namespace:
IBM.Data.DB2
- Assembly:
IBM.Data.DB2
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Public Property CommandType As CommandType
[C#]
public CommandType CommandType {get; set;}
[C++]
public: __property CommandType get_CommandType();
public: __property void set_CommandType(CommandType);
[JScript]
public function get CommandType() : CommandType;
public function set CommandType(CommandType);
Property value
One of the System.Data.CommandType values. The default is Text.
Exceptions
Exception type | Condition |
---|---|
ArgumentException | The value was not a valid CommandType. |
Remarks
When the CommandType property is set to StoredProcedure, you should set the CommandText property to the name of the stored procedure. 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.
When passing parameters to SQL statements or stored procedures called by a DB2®Command, the IBM® Data Server Provider for .NET supports named parameters or positioned parameters using parameter markers.
For more information, see "Using Stored Procedures with a Command" in the Microsoft(R) .NET Framework SDK documentation.
Example
[Visual Basic, C#] The following example creates an instance of a derived class DB2Command and sets some of its properties.
[Visual Basic]
Public Sub CreateMyDB2Command()
Dim myCommand As New DB2Command()
myCommand.CommandText = "SELECT * FROM EMPLOYEE ORDER BY EMPNO"
myCommand.CommandType = CommandType.Text
End Sub
[C#]
public void CreateMyDB2Command()
{
DB2Command myCommand = new DB2Command();
myCommand.CommandText = "SELECT * FROM EMPLOYEE ORDER BY EMPNO";
myCommand.CommandType = CommandType.Text;
}