Assembly: System.Data.OracleClient (in system.data.oracleclient.dll)
[TypeConverterAttribute(typeof(OracleConnectionStringBuilderConverter))] public ref class OracleConnectionStringBuilder sealed : public DbConnectionStringBuilder
/** @attribute TypeConverterAttribute(System.Data.OracleClient.OracleConnectionStringBuilder+OracleConnectionStringBuilderConverter) */ public final class OracleConnectionStringBuilder extends DbConnectionStringBuilder
TypeConverterAttribute(System.Data.OracleClient.OracleConnectionStringBuilder+OracleConnectionStringBuilderConverter) public final class OracleConnectionStringBuilder extends DbConnectionStringBuilder
The connection string builders allow developers to programmatically create syntactically correct connection strings, and to parse and rebuild existing connection strings, using properties and methods of the class. The connection string builder provides strongly typed properties corresponding to the known key/value pairs allowed by Oracle. The OracleConnectionStringBuilder class implements the ICustomTypeDescriptor interface. This means that the class works with Visual Studio .NET designers at design time. When developers use the designer to build strongly typed DataSets and strongly typed connections within Visual Studio .NET, the strongly typed connection string builder class will display the properties associated with its type and will also have converters that can map common values for known keys.
Developers needing to create connection strings as part of applications can use the OracleConnectionStringBuilder class to build and modify connection strings. The OracleConnectionStringBuilder class also makes it easy to manage connection strings stored in an application configuration file.
The OracleConnectionStringBuilder performs checks for valid key/value pairs. Therefore, this class cannot be used to create invalid connection strings. Trying to add invalid pairs will throw an exception. The OracleConnectionStringBuilder class maintains a fixed collection of synonyms, and when required, can perform the required translation to convert from a synonym to the corresponding well-known key name. For example, when you use the Item property to retrieve a value, you can specify a string that contains any synonym for the key you need. See the Item property for a full list of acceptable synonyms.
The OracleConnectionStringBuilder handles attempts to insert malicious entries. For example, the following code, using the default Item property (the indexer, in C#) correctly escapes the nested key/value pair.
Dim builder As New System.Data. _ OracleClient.OracleConnectionStringBuilder builder("Data Source") = "OracleDemo" builder("Integrated Security") = True builder("User ID") = "Mary;NewValue=Bad" System.Diagnostics.Debug.WriteLine(builder.ConnectionString)
System.Data.OracleClient.OracleConnectionStringBuilder builder = new System.Data.OracleClient.OracleConnectionStringBuilder(); builder["Data Source"] = "OracleDemo"; builder["integrated Security"] = true; builder["User ID"] = "Mary;NewValue=Bad"; System.Diagnostics.Debug.WriteLine(builder.ConnectionString);
The result is the following connection string that handles the invalid value in a safe manner by enclosing the User ID value in quotes:
Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad"
The following console application builds connection strings for an Oracle database. The code uses an OracleConnectionStringBuilder class to create the connection string, and then passes the ConnectionString property of the OracleConnectionStringBuilder instance to the constructor of the connection class. The example also parses an existing connection string, and demonstrates various ways of manipulating the connection string's contents.
This example includes a password to demonstrate how OracleConnectionStringBuilder works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.