cancel
Showing results for 
Search instead for 
Did you mean: 

CrystalReports ReportDocument in .net keeps database connections in sleeping mode in SQL

Former Member
0 Kudos

Hi,

I have a windows service written in C# which exports PDF reports. After successful execution of process, I see that there is last connection always left in database in sleeping mode. As i have hundreds of report, the sleeping connections keep on piling in database causing instability.

I use Crystal Reports for .NET Framework 4.0 version 13.0.2000.0 and Runtime version v2.0.50727

I get the sleeping connection for the last procedure in crystal report, when the following line runs

ReportDocument.Export(exportOptions);

Is it a known bug that crystal report leaves the last connection in database? I didn't found any forceful logoff method in C# to close the connection. Appreciate your help on this.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

In addition to what Don said, are you explicitly disposing of the ReportDocument after you export it?

Some of the Crystal SDK is still based on COM objects, which .NET doesn't memory manage very well, so you have to either use the ReportDocument in a "using" clause that will automatically dispose of it when you're done using it or you have to explicitly call .Dispose() on it when you're done with it. This should cause the report to disconnect from the database and free up any memory that it's using.

-Dell

Answers (2)

Answers (2)

All of those numbers are the Assembly and Framework version.

Need to know what verison of MS SQL Server and connecting via ODBC or OLE DB or JDBC?

Try the latest SP 22 and read the info for updating to SP21 and same info applies to SP 22 and above:

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

Don

Former Member
0 Kudos

Thanks for the input.

I already had implemented using block and also did the explicit call to .Dispose() method, but somehow the connection to database was still left in sleeping mode after the pdf was generated by crystal. The last executed proc in crystal was seen in database even after calling rpt.Close() method

Don's solution worked for me. I installed SP22 and the connections got closed when rpt.Close() method was called.

Thanks dell and don, appreciate your response on this.