Hi
We are loading and exporting a subreport to PDF with the below code, but when it loads the main report data is published but the subreports do not show any records.
If I run the report in Crystal Reports it works perfectly.
Any advice would be appreciated.
Thanks
B
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions
Dim CrReport As New ReportDocument
CrReport.Load(Path)
'logon for main reports
For i As Integer = 0 To CrReport.DataSourceConnections.Count - 1
CrReport.DataSourceConnections(0).SetLogon(gstrUsername, gstrPassword)
Next
'logon for sub reports
For i As Integer = 0 To CrReport.Subreports.Count - 1
For j As Integer = 0 To CrReport.Subreports.Item(i).DataSourceConnections.Count - 1
CrReport.Subreports.Item(i).DataSourceConnections(j).SetLogon(gstrUsername, gstrPassword)
Next
Next
CrDiskFileDestinationOptions.DiskFileName = "c:\temp\exportedreport.pdf"
CrExportOptions = CrReport.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
CrReport.Export()
We are loading and exporting a subreport to PDF with the below code, but when it loads the main report data is published but the subreports do not show any records.
If I run the report in Crystal Reports it works perfectly.
Any advice would be appreciated.
Thanks
B
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions
Dim CrReport As New ReportDocument
CrReport.Load(Path)
'logon for main reports
For i As Integer = 0 To CrReport.DataSourceConnections.Count - 1
CrReport.DataSourceConnections(0).SetLogon(gstrUsername, gstrPassword)
Next
'logon for sub reports
For i As Integer = 0 To CrReport.Subreports.Count - 1
For j As Integer = 0 To CrReport.Subreports.Item(i).DataSourceConnections.Count - 1
CrReport.Subreports.Item(i).DataSourceConnections(j).SetLogon(gstrUsername, gstrPassword)
Next
Next
CrDiskFileDestinationOptions.DiskFileName = "c:\temp\exportedreport.pdf"
CrExportOptions = CrReport.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
CrReport.Export()