1215482 - Database connection not released when connecting to MS Access in a .NET app

SAP Knowledge Base Articles - public

1215482 - Database connection not released when connecting to MS Access in a .NET app


A .NET web (ASP.NET) application uses OLE DB to connect to Microsoft Access. The application displays the report correctly.

However, after the ASP.NET page closes, the connection is not released and a lock file (*.MDL) is still in the folder where the database (*.MDB) is located.

It was expected that in an ASP.NET application, the objects would be released/destroyed once the web form was processed and displayed, however, the connection remains open.

Why is the connection not released?


In Visual Studio .NET, garbage collection is now carried out by the framework. This is carried out at different intervals. In order to flag the report object explicitly for collection, and to initiate that collection, use the following lines of code:

'crReport is the report object. Use the Dispose method to signal the object should be

'closed and shouldn't be used further


'GC is the garbage collection. Use the Collect method to force garbage collection


Place these lines of code in the 'Page_Unload' method of the web form to release the connection.



For further information, go to http://msdn.microsoft.com/library and search for 'Garbage Collection'. From the search results, open the Automatic Memory Management article.



VS.NET ASP DOTNET NET OLEDB MDB LOCKED CONNECTION Crystal Reports for Visual Studio Database Connection Microsoft Access Locked Connection , c2012505 , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem


SAP Crystal Reports, developer version for Microsoft Visual Studio ; SAP Crystal Reports, version for Visual Studio .NET 2008