dotConnect Universal Documentation
Devart.Data.Universal Namespace / UniConnection Class / CreateCommand Method
Example

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

    Return Value

    A UniCommand object.

    Remarks
    You can use this method as an alternative to common UniCommand constructors.
    Example
    In this sample UniCommand object is created. It is automatically associated with UniConnection that created it.
    public void CreateUniCommand(string myConnString)
    {
      UniConnection myConnection = new UniConnection(myConnString);
      UniCommand myCommand = myConnection.CreateCommand();
      myCommand.CommandText = "INSERT INTO Test.Dept(DeptNo, DName) Values(50, 'DEVELOPMENT')";
      myConnection.Open();
      try
      {
        myCommand.ExecuteNonQuery();
      }
      finally
      {
        myConnection.Close();
      }
    }
    Public Sub CreateUniCommand(ByVal myConnString As String)
      Dim myConnection As New UniConnection(myConnString)
      Dim myCommand As UniCommand = myConnection.CreateCommand()
      myCommand.CommandText = "INSERT INTO Test.Dept(DeptNo, DName) Values(50, 'DEVELOPMENT')"
      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