dotConnect for Dynamics 365 Documentation
Devart.Data.Dynamics Namespace / DynamicsConnection Class / CreateCommand Method
Example

CreateCommand Method (DynamicsConnection)
Creates and returns a DynamicsCommand object associated with the DynamicsConnection.
Creates and returns a DynamicsCommand object associated with the DynamicsConnection.
Syntax
'Declaration
 
Public Shadows Function CreateCommand() As DynamicsCommand
 

Return Value

A DynamicsCommand object.
Remarks
You can use this method as an alternative to common DynamicsCommand constructors.
Example
In this sample DynamicsCommand object is created. It is automatically associated with DynamicsConnection that created it.
public void CreateDynamicsCommand(string myConnString)
{
  DynamicsConnection dynamicsConnection = new DynamicsConnection(myConnString);
  DynamicsCommand dynamicsCommand = dynamicsConnection.CreateCommand();
  dynamicsCommand.CommandText = "INSERT INTO Contact (FirstName,LastName) VALUES ('John','Smith')";
  dynamicsConnection.Open();
  try
  {
    dynamicsCommand.ExecuteNonQuery();
  }
  finally
  {
    dynamicsConnection.Close();
  }
}
Public Sub CreateDynamicsCommand(ByVal myConnString As String)
  Dim dynamicsConnection As New DynamicsConnection(myConnString)
  Dim dynamicsCommand As DynamicsCommand = dynamicsConnection.CreateCommand()
  dynamicsCommand.CommandText = "INSERT INTO Contact (FirstName,LastName) VALUES ('John','Smith')"
  dynamicsConnection.Open()
  Try
    dynamicsCommand.ExecuteNonQuery()
  Finally
    dynamicsConnection.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