dotConnect for PostgreSQL Documentation
Connection Property
See Also  Example
Devart.Data.PostgreSql Namespace > PgSqlCommand Class : Connection Property

Gets or sets the PgSqlConnection used by this instance of the PgSqlCommand.


Visual Basic (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.


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.


The following example creates a PgSqlCommand and sets some of its properties.
C#csharpCopy Code
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;
C#Visual BasicCopy Code
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


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