Hi,
I am designing reports using
VB.NET and the Crystal Report .NET on Microsoft Visual Studio .NET 2003. The report will be viewed using CrytalReportViwer attached on the Windows Form. I will press one button called âPreviewâ every time I want to view the report.
The problem arise when I keep pressing the âPreviewâ button, the memory keep increasing, until certain stage, my PC hang! The problem will be much more crucial if I load large number of rows from database to the report dataset. Iâm not sure whether my style of coding has brought this problem or it just a normal scenario (loading large scale of data). Furthermore the rows of data taken from the database are always thousands.
Below are my codes:
Public Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
'Variable Declaration
Private rpt As ReportDocument
Private ds As New Dataset
Private tblName As DataTable
rpt = New RptCustomerList
'Execute Query
strSQL = "SELECT * from customer"
ODBCConnection1.Open()
ODBCDataAdapter1.SelectCommand.CommandText = strSQL
ODBCDataAdapter1.Fill(ds, tblName)
ODBCConnection1.Close()
'Load dataset to CrystalReport
rpt.SetDataSource(ds)
'Assign the report document to CrystalReportViwer
CrystalReportViwer1.ReportSource = rpt
End Sub
Is there anything not correct with the codes? Can anyone help me figure out how to solve this problem? Please.
Thanks in advance.