System.Data Namespace IDbConnection Class
Closes the connection to the data source.
[ VB ]
NotOverridable Public Sub Close ( )
[ C# ]
public void Close ( );
[ C++ ]
public: __sealed void Close ( );
[ C++ ]
public function Close ( );
Close is the preferred method of closing any open connection. The method rolls back any pending transactions. It then releases the connection to the connection pool, or closes the connection if connection pooling is disabled.
An application can call Close more than once without generating an exception.
The following example initializes and opens an SqlConnection, displays some of its properties, then closes the connection.
protected void Page_Load ( Object Src, EventArgs e ) {
// specify the data source
SqlConnection myConn = new SqlConnection (
"server=( local )\\NetSDK; trusted_connection=yes; database=pubs" );
// open the data connection
myConn.Open ( );
// retrieve properties of the connection object
...
// close the data connection
myConn.Close ( );
}
Show me
IDbConnection Members Open