Represents an open connection to a data source, and is implemented by .NET Framework data providers that access relational databases.
Assembly: System.Data (in System.Data.dll)
Gets or sets the string used to open a database.
Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.
Gets the name of the current database or the database to be used after a connection is opened.
Gets the current state of the connection.
Begins a database transaction.
Begins a database transaction with the specified IsolationLevel value.
Changes the current database for an open Connection object.
Closes the connection to the database.
Creates and returns a Command object associated with the connection.
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.(Inherited from IDisposable.)
Opens a database connection with the settings specified by the ConnectionString property of the provider-specific Connection object.
An application does not create an instance of theinterface directly, but creates an instance of a class that inherits .
Notes to Implementers:
To promote consistency among .NET Framework data providers, name the inheriting class in the form PrvClassname where Prv is the uniform prefix given to all classes in a specific .NET Framework data provider namespace. For example, Sql is the prefix of the SqlConnection class in the System.Data.SqlClient namespace.
When you inherit from theinterface, you should implement the following constructors:
Initializes a new instance of the PrvConnection class.
Initializes a new instance of the PrvConnection class when given a string containing the connection string.
The following example creates instances of the derived classes, SqlCommand and SqlConnection. The SqlConnection is opened and set as the Connection for the SqlCommand. The example then calls ExecuteNonQuery, and closes the connection. To accomplish this, the ExecuteNonQuery is passed a connection string and a query string that is a Transact-SQL INSERT statement.
Available since 1.1