asp.net.ph

OleDbConnection.Close Method

System.Data.OleDb Namespace   OleDbConnection Class


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

[ VB ]
NotOverridable Public Sub Close ( )

[ C# ]
public void Close ( );

[ C++ ]
public: __sealed void Close ( );

[ C++ ]
public function Close ( );

Remarks

The Close method rolls back any pending transactions. It then releases the connection to the connection pool, or closes the connection if connection pooling is disabled. If Close is called while handling a StateChange event, no additional StateChange events are fired.

An application can call Close more than one time. No exception is generated.

Example

The following example initializes and opens an OleDbConnection, displays some of its properties, then closes the connection.

protected void Page_Load ( Object Src, EventArgs e ) {
   // specify the data source
   OleDbConnection myConn = new OleDbConnection (
      "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + 
      Server.MapPath ( "~/app_data/pubs.mdb" ) );
   // open the data connection
   myConn.Open ( );

   // retrieve properties of the connection object
   ...

   // close the data connection
   myConn.Close ( );
}

 Show me 

See Also

OleDbConnection Members   Open   StateChange Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

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