dotConnect for Magento Documentation
Devart.Data.Magento Namespace / MagentoConnection Class / CreateCommand Method
Example

In This Topic
    CreateCommand Method (MagentoConnection)
    In This Topic
    Creates and returns a MagentoCommand object associated with the MagentoConnection.
    Creates and returns a MagentoCommand object associated with the MagentoConnection.
    Syntax
    'Declaration
     
    Public Shadows Function CreateCommand() As MagentoCommand
    public new MagentoCommand CreateCommand()

    Return Value

    A MagentoCommand object.
    Remarks
    You can use this method as an alternative to common MagentoCommand constructors.
    Example
    In this sample MagentoCommand object is created. It is automatically associated with MagentoConnection that created it.
    public void CreateMagentoCommand(string myConnString)
    {
      MagentoConnection magentoConnection = new MagentoConnection(myConnString);
      MagentoCommand magentoCommand = magentoConnection.CreateCommand();
      magentoCommand.CommandText = "INSERT INTO Customers (email, firstname, lastname) VALUES ('[email protected]', 'John', 'Smith')";
      magentoConnection.Open();
      try
      {
        magentoCommand.ExecuteNonQuery();
      }
      finally
      {
        magentoConnection.Close();
      }
    }
    Public Sub CreateMagentoCommand(ByVal myConnString As String)
      Dim magentoConnection As New MagentoConnection(myConnString)
      Dim magentoCommand As MagentoCommand = magentoConnection.CreateCommand()
      magentoCommand.CommandText = "INSERT INTO Customers (email, firstname, lastname) VALUES ('[email protected]', 'John', 'Smith')"
      magentoConnection.Open()
      Try
        magentoCommand.ExecuteNonQuery()
      Finally
        magentoConnection.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