asp.net.ph

OleDbConnection.ReleaseObjectPool Method

System.Data.OleDb Namespace   OleDbConnection Class


Indicates that the OleDbConnection object pooling can be cleared when the last underlying OLE DB Provider is released.

[ VB ]
Public Shared Sub ReleaseObjectPool ( )

[ C# ]
public static void ReleaseObjectPool ( );

[ C++ ]
public: static void ReleaseObjectPool ( );

[ C++ ]
public static function ReleaseObjectPool ( );

Remarks

The object pool is cached whenever one of the underlying OLE DB providers is created. ReleaseObjectPool can be called to free resources that would otherwise be reserved for pooled OleDbConnection objects.

You might want to call this method when the user is done using any OleDbConnection object, or if, for example, the connection object will not be used again for a period of time longer than OLE DB services would normally keep pooled connections alive.

The following must occur before the pool is finally disposed:

  1. Call Close to return the connection object to the pool.
  2. Allow each connection object to time out of the pool.
  3. Call ReleaseObjectPool.
  4. Invoke garbage collection.

Note that calling the method alone does not actually release the active connections that exist in the pool. Conversely, if you call Close on all active connections, and invoke garbage collection but do not call ReleaseObjectPool, the resources reserved for the pooled objects will remain available.

Example

The following example initializes an OleDbConnection, opens it, displays some of its properties, closes the connection and releases the object pool to conserve resources.

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 ( );
   OleDbConnection.ReleaseObjectPool ( );
}
See Also

OleDbConnection Members 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