'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 Id=test", and then reset the connection string to "Data Source=localhost", the UserId property is no longer set to test.
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 some valid names for values within the ConnectionString. These parameters are not dependent on underlying data provider. In addition to the enumerated items, you can use any connection string parameter specific to the data provider. Some of them will be parsed by Universal .NET to populate corresponding properties.
Name | Description |
---|---|
Database | The database to connect to. |
Data Source | The data source to connect to. |
Provider | Specifies provider to use for actual data access. Use GetProviderNames to obtain list of availale providers, or see the Supported Providers topic. |
Connection Lifetime | 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. The default value is 0 (connection always returns to pool). |
Max Pool Size | 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. |
Min Pool Size | The minimum number of connections allowed in the pool. The default value is 0. |
Pooling | If true, by default, the UniConnection object is drawn from the appropriate pool or is created and added to the appropriate pool. |
Port | The TCP port to connect to. |
Validate Connection | Specifies whether to validate connections that are being got from the pool. |
Note that in the native connection string of OLEDB provider you have to replace name provider with ole db provider to avoid conflict. For example, OLEDB connection to Oracle server can look as follows: provider=OLE DB;ole db provider=OraOLEDB.Oracle;Data Source=ora;Password=tiger;User ID=scott.
public void CreateUniConnection() { string myConnString1 = "Provider=SQL Server;Data Source=SERVER;Initial Catalog=Northwind;User ID=sa"; UniConnection myConnection1 = new UniConnection(myConnString1); myConnection1.Open(); }
Public Sub CreateUniConnection() Dim myConnString1 As String = "Provider=SQL Server;Data Source=SERVER;Initial Catalog=Northwind;User ID=sa" Dim myConnection1 As New UniConnection(myConnString1) myConnection1.Open() End Sub
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