Crystal Report now working on second load.
Hello everyone,
I need some advice on the following code
Code:
ds.Clear()
ConnecttoDatabase()
SQLCommand = vbNullString
SQLCommand += "SELECT * FROM producttable p "
SQLCommand += "WHERE NOT barcodenumber='' AND "
SQLCommand += "p.useonweb='1' AND p.itemstatus='1' AND NOT "
SQLCommand += "EXISTS(SELECT '' FROM productimage v "
SQLCommand += "WHERE v.productcode = p.barcodenumber) "
SQLCommand += "order by suppliername ASC;"
MySQLCmd = New MySqlCommand(SQLCommand, dbCon)
'open connection
dbCon.Open()
MySQLCmd.CommandText = SQLCommand
dr = MySQLCmd.ExecuteReader
With dr
Dim t As DataTable = ds.Tables.Add("Items")
t.Columns.Add("BarcodeNumber", Type.[GetType]("System.String"))
t.Columns.Add("SupplierCode", Type.[GetType]("System.String"))
t.Columns.Add("SupplierName", Type.[GetType]("System.String"))
t.Columns.Add("PoSDescription", Type.[GetType]("System.String"))
t.Columns.Add("SELDescription", Type.[GetType]("System.String"))
While .Read
Dim r As DataRow
r = t.NewRow()
r("BarcodeNumber") = .Item("BarcodeNumber")
r("SupplierCode") = .Item("Supplierproductcode")
r("SupplierName") = .Item("SupplierName")
r("PoSDescription") = .Item("PoSDescription")
r("SELDescription") = .Item("shelfedgelabelDescription")
t.Rows.Add(r)
End While
End With
Dim report As New ReportDocument()
Dim reportPath As String = Application.StartupPath & "\Report\ItemWithnoImages.rpt"
report.Load(reportPath)
report.SetDataSource(ds.Tables(1))
With frmReport
With .CrystalReportViewer1
.ReportSource = Nothing
.DisplayGroupTree = False
.Zoom(2) ' Full page
.ReportSource = report
.Refresh()
End With
frmProcessing.Close()
.Show()
.Focus()
End With
The report works first time with no problem but on any other time I get a blank report. What am I missing?
Re: Crystal Report now working on second load.
Put the code in a Try/Catch block and see if you get any errors.