Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crystal reports - close the database connection

This is in C#, Visual Studio 2008, crystal reports that came with VS2008

I've got a crystal report viewer form that resides in a DLL. The DLL is responsible for loading the crystal report (based on report filename), and displaying the report on the form.

When I'm done with the crystal report, i call dispose on the loaded reportdocument object. However, the database connection remains.

Crystal seems to detect that there are other connections (from my main application) to the same database, and keeps its connection open. The crystal connection is closed when the main applications database connection is closed.

Is there any way to force crystal to close its connection, with out closing the main applications database connection?

like image 971
user87945 Avatar asked Apr 07 '09 06:04

user87945


Video Answer


1 Answers

How are you connecting to the database, by creating your own connection at runtime via setting the authentication or are you letting Crystal do the connection via the stored connection in the report? If you are doing your own connection in any way, shape, or form, you have to manually close the connection and call the dispose before disposing the report.

It is quite possible this is a memory leak. I have experienced these before. There is also a memory leak issue with Crystal Reports and is talked about on their forum quite a bit but no fix was issued when I was using it a few years ago. I ditched Crystal for other options.

like image 170
TheCodeMonk Avatar answered Oct 07 '22 09:10

TheCodeMonk