Редактиране

Споделяне чрез


OracleConnectionStringBuilder Class

Definition

Caution

OracleConnectionStringBuilder has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260

Provides a simple way to create and manage the contents of connection strings used by the OracleConnection class.

public ref class OracleConnectionStringBuilder sealed : System::Data::Common::DbConnectionStringBuilder
[System.ComponentModel.TypeConverter(typeof(System.Data.OracleClient.OracleConnectionStringBuilder+OracleConnectionStringBuilderConverter))]
public sealed class OracleConnectionStringBuilder : System.Data.Common.DbConnectionStringBuilder
[System.ComponentModel.TypeConverter(typeof(System.Data.OracleClient.OracleConnectionStringBuilder+OracleConnectionStringBuilderConverter))]
[System.Obsolete("OracleConnectionStringBuilder has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260", false)]
public sealed class OracleConnectionStringBuilder : System.Data.Common.DbConnectionStringBuilder
[<System.ComponentModel.TypeConverter(typeof(System.Data.OracleClient.OracleConnectionStringBuilder+OracleConnectionStringBuilderConverter))>]
type OracleConnectionStringBuilder = class
    inherit DbConnectionStringBuilder
[<System.ComponentModel.TypeConverter(typeof(System.Data.OracleClient.OracleConnectionStringBuilder+OracleConnectionStringBuilderConverter))>]
[<System.Obsolete("OracleConnectionStringBuilder has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260", false)>]
type OracleConnectionStringBuilder = class
    inherit DbConnectionStringBuilder
Public NotInheritable Class OracleConnectionStringBuilder
Inherits DbConnectionStringBuilder
Inheritance
OracleConnectionStringBuilder
Attributes

Remarks

This type is deprecated and will be removed in a future version of .NET Framework. For more information, see Oracle and ADO.NET.

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;NewValue=Bad"
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"

Warning

Microsoft does not recommend providing your user name and password directly, because it's an insecure pattern. Where possible, use more secure authentication flows, such as Managed Identities for Azure resources, or Windows authentication for SQL Server.

Constructors

OracleConnectionStringBuilder()

Initializes a new instance of the OracleConnectionStringBuilder class.

OracleConnectionStringBuilder(String)

Initializes a new instance of the OracleConnectionStringBuilder class. The provided connection string provides the data for the instance's internal connection information.

Properties

BrowsableConnectionString

Gets or sets a value that indicates whether the ConnectionString property is visible in Visual Studio designers.

(Inherited from DbConnectionStringBuilder)
ConnectionString

Gets or sets the connection string associated with the DbConnectionStringBuilder.

(Inherited from DbConnectionStringBuilder)
Count

Gets the current number of keys that are contained within the ConnectionString property.

(Inherited from DbConnectionStringBuilder)
DataSource

Gets or sets the name of the Oracle data source to connect to.

Enlist

Gets or sets a value that indicates whether the pooler automatically enlists the connection in the creation thread's current transaction context.

IntegratedSecurity

Gets or sets a value that indicates whether "User ID" and "Password" are specified in the connection (when false) or whether the current Windows account credentials are used for authentication (when true).

IsFixedSize

Gets a value that indicates whether the OracleConnectionStringBuilder has a fixed size.

IsReadOnly

Gets a value that indicates whether the DbConnectionStringBuilder is read-only.

(Inherited from DbConnectionStringBuilder)
Item[String]

Gets or sets the value associated with the specified key. In C#, this property is the indexer.

Keys

Gets an ICollection that contains the keys in the OracleConnectionStringBuilder.

LoadBalanceTimeout

Gets or sets the minimum time, in seconds, for the connection to live in the connection pool before it is removed.

MaxPoolSize

Gets or sets the maximum number of connections allowed in the connection pool for this specific connection string.

MinPoolSize

Gets or sets the minimum number of connections allowed in the connection pool for this specific connection string.

OmitOracleConnectionName

Gets or sets the flag that enables transaction rollbacks on earlier versions of Oracle (prior to 8.1.7.4.1).

Password

Gets or sets the password for the Oracle account.

PersistSecurityInfo

Gets or sets a Boolean value that indicates if 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.

Pooling

Gets or sets a Boolean value that indicates whether the connection will be pooled, or whether each connection will be explicitly opened every time that the connection is requested.

Unicode

Gets or sets a Boolean value that indicates if the client supports the Unicode functionality available in later Oracle clients, or if it is non-Unicode aware.

UserID

Gets or sets the user ID to be used when connecting to Oracle.

Values

Gets an ICollection that contains the values in the OracleConnectionStringBuilder.

Methods

Add(String, Object)

Adds an entry with the specified key and value into the DbConnectionStringBuilder.

(Inherited from DbConnectionStringBuilder)
Clear()

Clears the contents of the OracleConnectionStringBuilder instance.

ClearPropertyDescriptors()

Clears the collection of PropertyDescriptor objects on the associated DbConnectionStringBuilder.

(Inherited from DbConnectionStringBuilder)
ContainsKey(String)

Determines whether the OracleConnectionStringBuilder contains a specific key.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
EquivalentTo(DbConnectionStringBuilder)

Compares the connection information in this DbConnectionStringBuilder object with the connection information in the supplied object.

(Inherited from DbConnectionStringBuilder)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetProperties(Hashtable)

Fills a supplied Hashtable with information about all the properties of this DbConnectionStringBuilder.

(Inherited from DbConnectionStringBuilder)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(String)

Removes the entry with the specified key from the OracleConnectionStringBuilder instance.

ShouldSerialize(String)

Indicates whether the specified key exists in this OracleConnectionStringBuilder instance.

ToString()

Returns the connection string associated with this DbConnectionStringBuilder.

(Inherited from DbConnectionStringBuilder)
TryGetValue(String, Object)

Retrieves a value corresponding to the supplied key from this OracleConnectionStringBuilder.

Explicit Interface Implementations

ICollection.CopyTo(Array, Int32)

Copies the elements of the ICollection to an Array, starting at a particular Array index.

(Inherited from DbConnectionStringBuilder)
ICollection.IsSynchronized

Gets a value indicating whether access to the ICollection is synchronized (thread safe).

(Inherited from DbConnectionStringBuilder)
ICollection.SyncRoot

Gets an object that can be used to synchronize access to the ICollection.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetAttributes()

Returns a collection of custom attributes for this instance of a component.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetClassName()

Returns the class name of this instance of a component.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetComponentName()

Returns the name of this instance of a component.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetConverter()

Returns a type converter for this instance of a component.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetDefaultEvent()

Returns the default event for this instance of a component.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetDefaultProperty()

Returns the default property for this instance of a component.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetEditor(Type)

Returns an editor of the specified type for this instance of a component.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetEvents()

Returns the events for this instance of a component.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetEvents(Attribute[])

Returns the events for this instance of a component using the specified attribute array as a filter.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetProperties()

Returns the properties for this instance of a component.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetProperties(Attribute[])

Returns the properties for this instance of a component using the attribute array as a filter.

(Inherited from DbConnectionStringBuilder)
ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor)

Returns an object that contains the property described by the specified property descriptor.

(Inherited from DbConnectionStringBuilder)
IDictionary.Add(Object, Object)

Adds an element with the provided key and value to the IDictionary object.

(Inherited from DbConnectionStringBuilder)
IDictionary.Contains(Object)

Determines whether the IDictionary object contains an element with the specified key.

(Inherited from DbConnectionStringBuilder)
IDictionary.GetEnumerator()

Returns an IDictionaryEnumerator object for the IDictionary object.

(Inherited from DbConnectionStringBuilder)
IDictionary.Item[Object]

Gets or sets the element with the specified key.

(Inherited from DbConnectionStringBuilder)
IDictionary.Remove(Object)

Removes the element with the specified key from the IDictionary object.

(Inherited from DbConnectionStringBuilder)
IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

(Inherited from DbConnectionStringBuilder)

Extension Methods

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to

See also