dotConnect for PostgreSQL Documentation
Devart.Data.PostgreSql Namespace / PgSqlCommand Class / Connection Property
Example

In This Topic
    Connection Property (PgSqlCommand)
    In This Topic
    Gets or sets the PgSqlConnection used by this instance of the PgSqlCommand.
    Syntax
    'Declaration
     
    Public Shadows Property Connection As PgSqlConnection
    public new PgSqlConnection Connection {get; set;}

    Property Value

    The connection to a data source. The default value is a null reference.
    Remarks

    PgSqlConnection specified in this property will carry out all operations executed with this PgSqlCommand.

    This property supports the InterForm technology.

    A single PgSqlConnection can be used by many PgSqlCommand objects on the assumption that all operations will be done consecutively. In other words, you can not execute an SQL statement while an asynchronous operation is in progress.

    Example
    The following example creates a PgSqlCommand and sets some of its properties.
    public void CreateCommand()
    {
      string mySelectQuery = "SELECT * FROM Test.Dept ORDER BY DeptNo";
      PgSqlCommand pgCommand = new PgSqlCommand(mySelectQuery);
      pgCommand.Connection = new PgSqlConnection(
        "host=server;database=test;user id=postgres;");
      pgCommand.CommandType = System.Data.CommandType.Text;
    }
    Public Sub CreateCommand()
      Dim mySelectQuery As String = _
        "SELECT * FROM Test.Dept ORDER BY DeptNo"
      Dim pgCommand As New PgSqlCommand(mySelectQuery)
      pgCommand.Connection = New PgSqlConnection( _
        "host=server;database=test;user id=postgres;")
      pgCommand.CommandType = System.Data.CommandType.Text
    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