'Declaration Public Overrides Property ConnectionString As String
public override string ConnectionString {get; set;}
'Declaration Public Overrides Property ConnectionString As String
public override string ConnectionString {get; set;}
Resetting the ConnectionString on a closed connection resets all connection string values (and related properties) including the password. For example, if you set a connection string that includes "User=postgres", and then reset the connection string to "Data Source=localhost", the UserId property is no longer set to "postgres".
The connection string is parsed immediately after being set. If errors in syntax are found when parsing, a runtime exception, such as System.ArgumentException, is generated. Other errors can be found only when an attempt is made to Open the connection.
The ConnectionString is similar to an OLE DB connection string. Values may be delimited by single or double quotes, (for example, name='value' or name="value"). Either single or double quotes may be used within a connection string by using the other delimiter, for example, name="value's" or name= 'value"s', but not name= 'value's' or name= ""value"". All blank characters, except those placed within a value or within quotes, are ignored. Keyword value pairs must be separated by a semicolon (;). If a semicolon is part of a value, it also must be delimited by quotes. No escape sequences are supported. The value type is irrelevant. Names are not case sensitive. Arguments names may occur only once in the connection string.
The following table lists the valid names for values within the ConnectionString.
| Name | Description |
|---|---|
| AllowDateTimeOffset -or- Allow DateTimeOffset | Determines whether to use the System.DateTimeOffset type instead of System.DateTime when PgSqlDataReader returns a timestamptz value. |
| Character Set | Specifies a character set used by the client. Actually, if this property is enabled, then the "SET NAMES <Charset>" query is executed on establishing a connection. Default value is an empty string. That means there is no action performed with charset on the client and on the server. |
| ApplicationName | Specifies the client application name. |
| Connection Lifetime | Determines the maximum time span (in seconds) a connection can remain in the pool: when a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span exceeds the value specified by Connection Lifetime. The default value is 0. |
| Connect Timeout -or- Connection Timeout | Specifies the length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error. The default value is 15. |
| Data Source -or- Host -or- Server | Specifies the name or IP address of host of PostgreSQL database to which to connect. |
| Database | Specifies the name of the database. If this parameter is not specified, it is assumed that name of the database is same as user name. |
| Default Command Timeout | Specifies the default time in seconds to wait while trying to execute a command before terminating the attempt and generating an error. 0 indicates no limit. |
| Default Fetch All | Sets the default value of the FetchAll property of PgSqlCommand instances, created via the CreateCommand method. If the FetchAll mode is enabled, PgSqlDataReader object retrieves all the querried data from the server on execution. |
| Enlist | Determines whether the connection is automatically enlisted in the current distributed transaction. The default value is true. This parameter is not available in Mobile Edition. This parameter is also not supported in .NET Standard 1.3 compatible assembly. |
| Force IPv4 | Determines whether authentication by IPv6 address is allowed, or IPv4 address is always used. The default value is false. |
| Initial Schema | Specifies the name of the schema to be used once a connection is opened. You can change it later if you need. By default it is schema 'Public'. |
| Ignore Unnamed Parameters | Specifies whether to disable treating the '?' character in CommandText as an unnamed parameter. |
| Initialization Command | Specifies a database-specific command that should be executed immediately after establishing the connection. |
| Integrated Security | Determines whether to use a secure authentication with single sign-on (GSSAPI or SSPI, depending on the server). |
| Join Statement Notices | Determines whether all the notices, raised during the statement execution, will be returned together in one InfoMessage event after the statement execution, or each notice will be returned in a separate InfoMessage event. |
| Keep Alive | Specifies whether to send TCP keep-alive packets and the interval at which they are sent in seconds. Default value is 0, which means that the packets are not sent. |
| Keep Connected | Specifies whether to perform periodic ping calls to PostgreSQL when a connection is inactive (in order to always know if the connection is still valid) and the interval at which the calls are made in seconds. Default value is 0, which means that the calls are not made. |
| License Key | Specify your license key in this parameter. This is required only when using .NET Standard compatible assemblies. See Licensing for more information. |
| Max Pool Size | Specifies the maximum number of connections allowed in the pool. Setting the Max Pool Size value of the ConnectionString can affect performance. The default value is 100. In the case of forgotten open transactions, the number of connections can exceed Max Pool Size. |
| Min Pool Size | Specifies the minimum number of connections allowed in the pool. The default value is 0. |
| Password | Specifies the password for the PostgreSQL login account. |
| Persist Security Info | Determines whether security-sensitive information, such as the password, is excluded from the connection string when the connection is open or has previously been opened. Possible values are True, False, Yes, and No. Note: Reassigning the connection string restores all connection string properties, including the password. |
| Pooling | Determines whether, by default, the PgSqlConnection object is drawn from the appropriate pool or is created and added to the appropriate pool, when set to true. |
| Port | Specifies the port of PostgreSQL database to which to connect. The default value is 5432. |
| Protocol | Specifies the Frontend/Backend Protocol version. Available values are 2 and 3. Set the parameter to 2 for the protocol version 2.0 or to 3 for protocol version 3.0. Can be applied only for PostgreSQL server versions 7.4 or higher, for earlier versions of PostgreSQL this parameter must be explicitly set to 2. To execute several statements in the same query set procol to 2 version. The default value is 3. |
| Proxy Host | Specifies the host name or IP address of proxy server. |
| Proxy Password | Specifies the password for the proxy server account. |
| Proxy Port | Specifies the port number of the proxy server. The default value is 3128. |
| Proxy User | Specifies the proxy server account name. |
| Run Once Command | Specifies a database-specific command that should be executed immediately after establishing the connection. Unlike Initialization Command, it is not executed for connections obtained from the connection pool. |
| SSH Authentication Type | Specifies the client authentication method. See Devart.Common.SshAuthenticationType for additional information. |
| SSH Cipher List | Specifies the list of ciphers that client agrees to use. See PgSqlConnectionStringBuilder.SshCipherList for additional information. |
| SSH Host | Specifies the name or ip address of SSH server. |
| SSH Host Key | Specifies the location of the public key on the client side to verify the server host key during establishing connection. |
| SSH KeyExchange Algorithms | Specifies the algorithms to securely establish a shared encryption key between the client and the server. |
| SSH MAC Algorithms | Specifies the algorithms to verify the integrity and authenticity of data exchanged between the client and the server. |
| SSH Passphrase | Specifies the passphrase for the client key. |
| SSH Password | Specifies the user password on SSH server. |
| SSH Port | Specifies the number of port on SSH server to connect. |
| SSH Private Key | Specifies the location of the private key to use. |
| SSH Strict Host Key Check | Indicates whether the host key is verified during establishing connection. |
| SSH User | Specifies the user id on SSH server. |
| SSL CA Cert | Specifies the location of the authority SSL certificate. |
| Ssl Cert | Specifies the location of the client SSL certificate. |
| Ssl Cipher List | Specifies the list of ciphers that client agrees to use. |
| Ssl Key | Specifies the location of the user's private key. |
| Ssl Mode | Specifies the SSL connection priority. May be Disable, Allow, Prefer, and Require. The default value is Disable, which means that only an unencrypted SSL connection will be attempted. |
| SSL TLS Protocol | Specifies the maximal TLS version to report to the server when establishing a connection. Supported values are "1.0", "1.1", and "1.2". The default value is "1.1". |
| Target Session | Determines how the host to connect to is selected from the list when multiple hosts are specified in the Host connection string parameter. See Load Balancing and Failover for more information. |
| Transaction Error Behavior | Determines whether to roll back a transaction automatically when an error occurs inside the transaction. |
| Transaction Scope Local | Restricts several connections with the same connection string (which includes "Transaction Scope Local=true;") within a scope of TransactionScope to using only one connection internally. The default value is false. Not available in Mobile Edition. This parameter is also not supported in .NET Standard 1.3 compatible assembly. |
| Unicode | Sets client charset to UTF8 and converts client data according to this charset, when set to true. Default value is false in the assemblies for Full .NET Framework, but true for .NET Standard compatible assemblies. |
| UnpreparedExecute | Determines whether unprepared execute mode is used in PgSqlCommand instances by default, when set to true. |
| User ID -or- User | Specifies the PostgreSQL login account. |
| Use Session Timezone | Gets or sets a Boolean value indicating whether the current session's time zone should be used to convert the requested PostgreSQL date/time values. |
| Validate Connection | Specifies whether to validate connections that are being got from the pool. |
public void CreatePgSqlConnection() { string myConnString1 = "host=server;database=test;user id=postgres;"; PgSqlConnection pgConnection1 = new PgSqlConnection(myConnString1); pgConnection1.Open(); }
Public Sub CreatePgSqlConnection() Dim myConnString1 As String = _ "host=server;database=test;user id=postgres;" Dim pgConnection1 As New PgSqlConnection(myConnString1) pgConnection1.Open() End Sub