dotConnect for PostgreSQL Documentation
CreateCommand Method
See Also  Example support@devart.com
Devart.Data.PostgreSql Namespace > PgSqlConnection Class : CreateCommand Method

Creates and returns a PgSqlCommand object associated with the PgSqlConnection. Creates and returns a PgSqlCommand object associated with the PgSqlConnection.

Syntax

Visual Basic (Declaration) 
Public Shadows Function CreateCommand() As PgSqlCommand
C# 
public new PgSqlCommand CreateCommand()

Return Value

A PgSqlCommand object.

Remarks

You can use this method as an alternative to common PgSqlCommand constructors.

Example

In this sample PgSqlCommand object is created. It is automatically associated with PgSqlConnection that created it.
C#csharpCopy Code
public void CreatePgSqlCommand(string myConnString)
{
  PgSqlConnection pgConnection = new PgSqlConnection(myConnString);
  PgSqlCommand pgCommand = pgConnection.CreateCommand();
  pgCommand.CommandText = "INSERT INTO DEPT VALUES (50,'Development','Philadelphia')";
  pgConnection.Open();
  try
  {
    pgCommand.ExecuteNonQuery();
  }
  finally
  {
    pgConnection.Close();
  }
}
C#Visual BasicCopy Code
Public Sub CreatePgSqlCommand(ByVal myConnString As String)
  Dim pgConnection As New PgSqlConnection(myConnString)
  Dim pgCommand As PgSqlCommand = pgConnection.CreateCommand()
  pgCommand.CommandText = "INSERT INTO DEPT VALUES (50,'Development','Philadelphia')"
  pgConnection.Open()
  Try
    pgCommand.ExecuteNonQuery()
  Finally
    pgConnection.Close()
  End Try
End Sub

Requirements

Platforms:Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8, Windows 10, Windows Server 2012 family.

See Also