asp.net.ph

IDbConnection.Close Method

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 ( );

Remarks

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.

Example

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 

See Also

IDbConnection Members   Open Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph