dotConnect for Oracle Documentation
Devart.Data.Oracle Namespace / OracleConnection Class / CreateCommand Method / CreateCommand() Method
Example

On this page
    CreateCommand() Method
    On this page
    Creates and returns a OracleCommand object associated with the OracleConnection.
    Syntax
    'Declaration
     
    Public Overloads Shadows Function CreateCommand() As OracleCommand
    public new OracleCommand CreateCommand()

    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();
      myCommand.CommandText = "INSERT INTO DEPT VALUES (50,'Development','Philadelphia')";
      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()
      myCommand.CommandText = "INSERT INTO DEPT VALUES (50,'Development','Philadelphia')"
      myConnection.Open()
      Try
        myCommand.ExecuteNonQuery()
      Finally
        myConnection.Close()
      End Try
    End Sub
    See Also