Skip to Content
0
Former Member
Jul 31, 2016 at 02:03 AM

Help needed with the old 75 print limit max issue.

41 Views

I am currently creating a windows application (using Visual Studio 2013) that prints book lists for a large number of students, approximately 800. I have separated the students into two year groups and then into alphabetical groups by surname so that each print run will not exceed the 75 limit.

I wish to be able to free up memory so that the application can print all small groups of book lists without restarting the application each time!

This is what I've done....

Step 1: Created a form where choices are made. i.e. Which group to print.

Step 2: Form is created to hold the report.

TestForm tfBa = new TestForm("B", "lower", textBoxBookListP.Text.ToString()); //(Surname letter, Year, Printer To Use)

Step 3: In the TestForm.cs

public TestForm(String alpha, String range, String printer)

{

InitializeComponent();

ReportDocument rptDoc = new ReportDocument();

CrystalReportViewer crystalReportViewer1 = new CrystalReportViewer();

rptDoc.Load(@"C:\Users\christopher.sheedy\documents\visual studio 2013\Projects\NEAS2\NEAS2\MultiBookListReport.rpt");

rptDoc.SetParameterValue("StudentNameRange", alpha);

rptDoc.SetParameterValue("NameRanges", range);

crystalReportViewer1.ReportSource = rptDoc;

crystalReportViewer1.Refresh();

this.Controls.Add(crystalReportViewer1);

crystalReportViewer1.Dock = DockStyle.Fill;

rptDoc.PrintOptions.PrinterName = printer;

rptDoc.PrintToPrinter(1, false, 0, 0);

rptDoc.Close();

rptDoc.Dispose();

crystalReportViewer1.Dispose();

this.Close();

this.Dispose();

GC.Collect();

}

When this application is run the first report works fine but once a second report is run (exceeds the 75 limit) then the application throws a database connection error. I know that the 75 max limit is causing the issue because to can show the report and see that the error only appears once the 76th report is selected.

I have tried to release memory as best i can but it doesn't seem to work.

Any suggestion on this implementation? I presume this is a common problem.

Cheers

Sheeds