content
| - %META:TOPICPARENT{name="VirtAdoNet35Provider"}%
---+ Virtuoso ADO.NET Provider <code><nowiki>ConnectionString</nowiki></code> Property
The Virtuoso ADO.NET Provider <code><nowiki>ConnectionString</nowiki></code> property implements the <code><nowiki>IDbConnection.ConnectionString</nowiki></code> property to get or set the string used to open a Virtuoso database connection, and includes the source database name and other parameters needed to establish the initial connection. The default value is an empty string.
<code><nowiki>ConnectionString</nowiki></code> has the following syntax. Each connection string is a sequence of settings Individual settings are separated by semicolons. Each setting is a pair of name and value delimited by the equal sign. Whitespace is ignored on either side of both names and values. Names are case insensitive. The value part can be quoted by either single or double quote characters or remain unquoted at all. However if it includes a semicolon, single quote, or double quote characters, it must be enclosed in either type of quotes. To embed the same character that is used for enclosing the value the character within the value must be doubled.
The following table lists the valid names for values within the <code><nowiki>ConnectionString</nowiki></code>.
| *Name* | *Default* | *Description* |
| <b><code>Connect Timeout</code></b> <i>or</i>%BR% <b><code>Connection Timeout</code></b> | <code>15</code> | The number of seconds to wait for a connection to the server before terminating the attempt and generating an error. |
| <b><code>Connection Lifetime</code></b> | <code>0</code> | 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 (in seconds) exceeds the value specified by connection lifetime. Useful in clustered configurations to force load balancing between a running server and a server just brought on-line. |
| <b><code>Charset</code></b> | <code>utf-16</code> | Specifies the character set to be used by the provider when passing string values to and from the database. Must be set to <code>utf-8</code> to handle Unicode strings passed in SPARQL/SPASQL queries of RDF data. |
| <b><code>Data Source</code></b> <i>or</i>%BR% <b><code>Server</code></b> <i>or</i>%BR% <b><code>Address</code></b> <i>or</i>%BR% <b><code>Network Address</code></b> <i>or</i>%BR% <b><code>Host</code></b> | | The name or network address of the instance of Virtuoso server to which to connect. Can take comma delimited list of instances for connection fail over. |
| <b><code>Encrypt</code></b> | <code>false</code> | Specifies if the connection must be SSL encrypted. Currently encryption only works with an ODBC-based provider. |
| <b><code>Enlist</code></b> | <code>true</code> | When true, the pooler automatically enlists the connection in the creation thread's current transaction context. |
| <b><code>Initial Catalog</code></b> <i>or</i>%BR% <b><code>Database</code></b> | | The name of the database. |
| <b><code>Max Pool Size</code></b> | <code>100</code> | The maximum number of connections allowed in the pool. |
| <b><code>Min Pool Size</code></b> | <code>0</code> | The minimum number of connections allowed in the pool. |
| <b><code>Password</code></b> <i>or</i>%BR% <b><code>Pwd</code></b> | | The password for the Virtuoso account logging on. |
| <b><code>Persist Security Info</code></b> | <code>false</code> | When set to 'false', security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open State. Resetting the connection string resets all connection string values including the password. |
| <b><code>Pooling</code></b> | <code>true</code> | When true, the <code><nowiki>VirtuosoConnection</nowiki></code> object is drawn from the appropriate pool, or if necessary, is created and added to the appropriate pool. |
| <b><code><nowiki>RoundRobin</nowiki></code></b> | <code>false</code> | Enables load balancing in which case the server for the connection is chosen at random from the comma delimited provided as for a Failover connection. |
| <b><code>User ID</code></b> <i>or</i>%BR% <b><code>Uid</code></b> | | The Virtuoso login name. |
---++ Remarks
The <code><nowiki>ConnectionString</nowiki></code> is similar to an OLE DB connection string, but is not identical. Unlike OLE DB or ADO, the connection string that is returned is the same as the user set <code><nowiki>ConnectionString</nowiki></code> minus security information if the <code>Persist Security Info</code> value is set to <code>false</code> (default). The Virtuoso ADO.NET Data Provider neither persists nor returns the password in a connection string unless you set <code>Persist Security Info</code> to <code>true</code>.
The <code><nowiki>ConnectionString</nowiki></code> property can be set only when the connection is closed. Many of the connection string values have corresponding read-only properties. When the connection string is set, all of these properties are updated, except when an error is detected; in this case, none of the properties are updated. <code><nowiki>VirtuosoConnection</nowiki></code> properties return only those settings contained in the <code><nowiki>ConnectionString</nowiki></code>.
Resetting the <code><nowiki>ConnectionString</nowiki></code> 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 "<code><nowiki>Database=Demo</nowiki></code>", and then reset the connection string to "<code><nowiki>Data Source=myserver;User ID=dba;Password=dba</nowiki></code>", the Database property is no longer set to <code>Demo</code>.
The connection string is parsed immediately after being set. If errors in syntax are found when parsing, a runtime exception (e.g., <code><nowiki>ArgumentException</nowiki></code>) is generated. Other errors can be found only when an attempt is made to open the connection.
CategoryDocumentation CategoryVirtuoso CategoryDotNET CategoryEntityFrameworks CategoryWebSite
|