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

CreateCommand Method (MagentoConnection)
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
 

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 adobe commerceConnection = new MagentoConnection(myConnString);
  MagentoCommand adobe commerceCommand = adobe commerceConnection.CreateCommand();
  adobe commerceCommand.CommandText = "INSERT INTO Customers (email, firstname, lastname) VALUES ('smithj@test1.com', 'John', 'Smith')";
  adobe commerceConnection.Open();
  try
  {
    adobe commerceCommand.ExecuteNonQuery();
  }
  finally
  {
    adobe commerceConnection.Close();
  }
}
Public Sub CreateMagentoCommand(ByVal myConnString As String)
  Dim adobe commerceConnection As New MagentoConnection(myConnString)
  Dim adobe commerceCommand As MagentoCommand = adobe commerceConnection.CreateCommand()
  adobe commerceCommand.CommandText = "INSERT INTO Customers (email, firstname, lastname) VALUES ('smithj@test1.com', 'John', 'Smith')"
  adobe commerceConnection.Open()
  Try
    adobe commerceCommand.ExecuteNonQuery()
  Finally
    adobe commerceConnection.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