Top
Enterprise Postgres 17 SP1 Application Development Guide

11.2.3 Using a .NET Data Provider

Set the following information in the connection string of NpgsqlConnection, or in the data source.

Table 11.3 Information to be set

Argument

Explanation

host1
host2

Specify the IP address or host name.

port1
port2

Specify the port number for the connection.

TargetSessionAttributes

Specify the selection sequence of the servers to which the application will connect.
Refer to "Target server" for details.


When specifying a connection string

Specify the following connection string:

host1[:port1],host2[:port2];[Target Session Attributes={any | primary | standby | prefer-primary | prefer-standby | read-write | read-only}];
  • If the port number is omitted from the host string, the value specified for the Port keyword of the connection string will be used. Refer to "4.3.3 Connection String" for information on the Port keyword.

  • When using IPV6, specify the host in the "[host]" (with square brackets) format.

  • If the target server type is omitted, the value will be any.

    [Example]

    host=[2001:Db8::1234]:27500,192.168.1.1:27500;

When specifying the NpgsqlConnectionStringBuilder property

Specify the Host property of the data source in the following format:

host1[:port1],host2[:port2]
  • If the port number is omitted from the host string, the value specified in the Port property will be used. Also, if the Port property is omitted, the default is 27500.


Specify the TargetSessionAttributes property of the data source in the following format:

any | primary | standby | prefer-primary | prefer-standby | read-write | read-only
  • If the target server type is omitted, the value will be any.

Note

If using the connection parameter Timeout, this value is applied for connections to each of the specified hosts. If both multiplexed database servers have failed, the connection will time out when a time equal to double the Timeout value elapses.