dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OracleConnection Class / CreateCommand Method / CreateCommand(String,CommandType) Method
The command text to assign to the command object.
One of the System.Data.CommandType values.
Example

In This Topic
    CreateCommand(String,CommandType) Method
    In This Topic
    Creates and returns a OracleCommand object associated with the OracleConnection, and having the specified command text and command type.
    Syntax
    'Declaration
     
    Public Overloads Function CreateCommand( _
       ByVal commandText As String, _
       ByVal commandType As CommandType _
    ) As OracleCommand
    public OracleCommand CreateCommand( 
       string commandText,
       CommandType commandType
    )

    Parameters

    commandText
    The command text to assign to the command object.
    commandType
    One of the System.Data.CommandType values.

    Return Value

    A OracleCommand object.
    Remarks
    You can use this method as an alternative to common OracleCommand constructors.
    Example
    In this sample OracleCommand object is created. It is automatically associated with OracleConnection that created it.
    public void CreateOracleCommand(string myConnString)
    {
            OracleConnection myConnection = new OracleConnection(myConnString);
            OracleCommand myCommand = myConnection.CreateCommand("INSERT INTO Test.Dept(DeptNo, DName) Values(50, 'DEVELOPMENT')", CommandType.Text);
            myConnection.Open();
            try
            {
                    myCommand.ExecuteNonQuery();
            }
            finally
            {
                    myConnection.Close();
            }
    }
    Public Sub CreateOracleCommand(ByVal myConnString As String)
            Dim myConnection As New OracleConnection(myConnString)
            Dim myCommand As OracleCommand = myConnection.CreateCommand("INSERT INTO Test.Dept(DeptNo, DName) Values(50, 'DEVELOPMENT')", CommandType.Text)
            myConnection.Open()
            Try
                    myCommand.ExecuteNonQuery()
            Finally
                    myConnection.Close()
            End Try
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also