DbConnection Class

DbConnection Class

 

Represents a connection to a database.

Namespace:   System.Data.Common
Assembly:  System.Data (in System.Data.dll)

System::Object
  System::MarshalByRefObject
    System.ComponentModel::Component
      System.Data.Common::DbConnection
        System.Data.EntityClient::EntityConnection
        System.Data.Odbc::OdbcConnection
        System.Data.OleDb::OleDbConnection
        System.Data.OracleClient::OracleConnection
        System.Data.SqlClient::SqlConnection

public ref class DbConnection abstract : Component, IDbConnection, 
	IDisposable

NameDescription
System_CAPS_protmethodDbConnection()

Initializes a new instance of the DbConnection class.

NameDescription
System_CAPS_protpropertyCanRaiseEvents

Gets a value indicating whether the component can raise an event.(Inherited from Component.)

System_CAPS_pubpropertyConnectionString

Gets or sets the string used to open the connection.

System_CAPS_pubpropertyConnectionTimeout

Gets the time to wait while establishing a connection before terminating the attempt and generating an error.

System_CAPS_pubpropertyContainer

Gets the IContainer that contains the Component.(Inherited from Component.)

System_CAPS_pubpropertyDatabase

Gets the name of the current database after a connection is opened, or the database name specified in the connection string before the connection is opened.

System_CAPS_pubpropertyDataSource

Gets the name of the database server to which to connect.

System_CAPS_protpropertyDbProviderFactory

Gets the DbProviderFactory for this DbConnection.

System_CAPS_protpropertyDesignMode

Gets a value that indicates whether the Component is currently in design mode.(Inherited from Component.)

System_CAPS_protpropertyEvents

Gets the list of event handlers that are attached to this Component.(Inherited from Component.)

System_CAPS_pubpropertyServerVersion

Gets a string that represents the version of the server to which the object is connected.

System_CAPS_pubpropertySite

Gets or sets the ISite of the Component.(Inherited from Component.)

System_CAPS_pubpropertyState

Gets a string that describes the state of the connection.

NameDescription
System_CAPS_protmethodBeginDbTransaction(IsolationLevel)

Starts a database transaction.

System_CAPS_pubmethodBeginTransaction()

Starts a database transaction.

System_CAPS_pubmethodBeginTransaction(IsolationLevel)

Starts a database transaction with the specified isolation level.

System_CAPS_pubmethodChangeDatabase(String^)

Changes the current database for an open connection.

System_CAPS_pubmethodClose()

Closes the connection to the database. This is the preferred method of closing any open connection.

System_CAPS_pubmethodCreateCommand()

Creates and returns a DbCommand object associated with the current connection.

System_CAPS_protmethodCreateDbCommand()

Creates and returns a DbCommand object associated with the current connection.

System_CAPS_pubmethodCreateObjRef(Type^)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Releases all resources used by the Component.(Inherited from Component.)

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the Component and optionally releases the managed resources.(Inherited from Component.)

System_CAPS_pubmethodEnlistTransaction(Transaction^)

Enlists in the specified transaction.

System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.(Inherited from Component.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetSchema()

Returns schema information for the data source of this DbConnection.

System_CAPS_pubmethodGetSchema(String^)

Returns schema information for the data source of this DbConnection using the specified string for the schema name.

System_CAPS_pubmethodGetSchema(String^, array<String^>^)

Returns schema information for the data source of this DbConnection using the specified string for the schema name and the specified string array for the restriction values.

System_CAPS_protmethodGetService(Type^)

Returns an object that represents a service provided by the Component or by its Container.(Inherited from Component.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodOnStateChange(StateChangeEventArgs^)

Raises the StateChange event.

System_CAPS_pubmethodOpen()

Opens a database connection with the settings specified by the ConnectionString.

System_CAPS_pubmethodOpenAsync()

An asynchronous version of Open, which opens a database connection with the settings specified by the ConnectionString. This method invokes the virtual method OpenAsync with CancellationToken.None.

System_CAPS_pubmethodOpenAsync(CancellationToken)

This is the asynchronous version of Open. Providers should override with an appropriate implementation. The cancellation token can optionally be honored.

The default implementation invokes the synchronous Open call and returns a completed task. The default implementation will return a cancelled task if passed an already cancelled cancellationToken. Exceptions thrown by Open will be communicated via the returned Task Exception property.

Do not invoke other methods and properties of the DbConnection object until the returned Task is complete.

System_CAPS_pubmethodToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.(Inherited from Component.)

NameDescription
System_CAPS_pubeventDisposed

Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)

System_CAPS_pubeventStateChange

Occurs when the state of the event changes.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDbConnection::BeginTransaction()

Begins a database transaction.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDbConnection::BeginTransaction(IsolationLevel)

Begins a database transaction with the specified IsolationLevel value.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDbConnection::CreateCommand()

Creates and returns a DbCommand object that is associated with the current connection.

Notes to Inheritors:

When you inherit from DbConnection, you must override the following members: Close, BeginDbTransaction, ChangeDatabase, CreateDbCommand, Open, and StateChange. You must also provide the following properties: ConnectionString, Database, DataSource, ServerVersion, and State.

Universal Windows Platform
Available since 10
.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft