Symptom
When using Crystal Reports XI Release 2 and Visual Studio .NET,
fields are stripped from the subreport when data is pushed to
the report using ADO.NET objects.
Resolution
To resolve, call
SetDataSource on the subreport first, then set the
main report"s data source. Fields will no longer be dropped
from the subreport.
Basic code snippet:
Dim
crReportDocument As New
CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crSubreportObject As SubreportObject
Dim crSubreportDocument As ReportDocument
Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crSubreportObject As SubreportObject
Dim crSubreportDocument As ReportDocument
'load
the report
crReportDocument.Load(System.Windows.Forms.Application.StartupPath)
crReportDocument.Load(System.Windows.Forms.Application.StartupPath)
'loop
through all the sections to find all the report objects
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
'loop through all the report objects to find all the subreports
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject Then
'you will need to typecast the reportobject to a subreport
'object once you find it
crSubreportObject = CType(crReportObject, SubreportObject)
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
'loop through all the report objects to find all the subreports
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject Then
'you will need to typecast the reportobject to a subreport
'object once you find it
crSubreportObject = CType(crReportObject, SubreportObject)
'open the subreport object
crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
'pass the dataset to the subreport(s)
crSubReportDocument.SetDataSource(dataSet)
crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
'pass the dataset to the subreport(s)
crSubReportDocument.SetDataSource(dataSet)
End If
Next
Next
Next
Next
'pass
the dataset to the main report
crReportDocument.SetDataSource(dataSet)
'view the report
CrystalReportViewer1.ReportSource = crReportDocument
crReportDocument.SetDataSource(dataSet)
'view the report
CrystalReportViewer1.ReportSource = crReportDocument
Keywords
command table subreport data no stripped fields net , 5663534 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To
Product
SAP Crystal Reports XI ; SAP Crystal Reports XI R2