Results 1 to 2 of 2

Thread: Crystal Report now working on second load.

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2014
    Location
    Northampton, UK
    Posts
    59

    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?

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,508

    Re: Crystal Report now working on second load.

    Put the code in a Try/Catch block and see if you get any errors.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width