locked
Crystal Report PDF created - but no data RRS feed

  • Question

  • User1875103063 posted

    I have written the code below to create and populate a crystal report, and then save it to a PDF file without displaying it.  The pdf file is created, but the 4 data fields are blank.

            Dim reportData As New DataTable("MyReportTable")
            reportData.Columns.Add("EMPLOYEE_NAME")
            reportData.Columns.Add("EMPLOYEE_ID")
            reportData.Columns.Add("DEPARTMENT")
            reportData.Columns.Add("DATE")
            Dim row As DataRow = reportData.NewRow()
    
            row("EMPLOYEE_NAME") = "FirstName LastName"
            row("EMPLOYEE_ID") = "My ID"
            row("DEPARTMENT") = "123"
            row("DATE") = "04/16/2013"
    
            Dim report As New ReportDocument()
            report.Load(Request.PhysicalApplicationPath & "\MyReport.rpt")
            report.Database.Tables("MyReportTable").SetDataSource(reportData)
    
            Dim exportOptions As New ExportOptions
            Dim diskFileDestinationOptions As New DiskFileDestinationOptions()
            Dim formatTypeOptions As New PdfRtfWordFormatOptions()
    
            diskFileDestinationOptions.DiskFileName = "C:\foo.pdf"
    
            exportOptions.ExportDestinationType = ExportDestinationType.DiskFile
            exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
            exportOptions.DestinationOptions = diskFileDestinationOptions
            exportOptions.FormatOptions = formatTypeOptions
            report.Export(exportOptions)

    Can anyone see if I have done something wrong?  Is there a better way to fill a report's datasource without directly using a table?

    Tuesday, April 16, 2013 1:16 PM

Answers

  • User-1137493631 posted

    try add row to datatable something like this,

    row("EMPLOYEE_NAME") = "FirstName LastName"
            row("EMPLOYEE_ID") = "My ID"
            row("DEPARTMENT") = "123"
            row("DATE") = "04/16/2013"
    reportData .Rows.add(row)



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 16, 2013 1:19 PM

All replies

  • User-1137493631 posted

    try add row to datatable something like this,

    row("EMPLOYEE_NAME") = "FirstName LastName"
            row("EMPLOYEE_ID") = "My ID"
            row("DEPARTMENT") = "123"
            row("DATE") = "04/16/2013"
    reportData .Rows.add(row)



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 16, 2013 1:19 PM
  • User1875103063 posted

    Thanks!

     

    I knew it had to be something simple.

    Tuesday, April 16, 2013 1:21 PM