So i need to add a supreport to the main report that i have and im not sure how to do that so i google it and im not getting it right
can anyone help me here please :$
Dim strConnection As String = "Server=OADMIN\SQLEXPRESS; Database=EHV2;uid=admin;Password=ehvgem"
Dim Connection As New SqlConnection(strConnection)
Dim norden As String
norden = TextBox1.Text.ToString
Dim strSQL As String = " (SQL Query) "
Dim DA As New SqlDataAdapter(strSQL, Connection)
Dim DS As New DataSet
Dim strReportName As String
DA.Fill(DS)
'Pass the reportname to string
strReportName = "poReport2"
'Get the Report Location
Dim strReportPath As String = "C:\" & strReportName & ".rpt"
'Check file exists
If Not IO.File.Exists(strReportPath) Then
Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
End If
'Assign the datasource and set the properties for Report viewer
Dim rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rptDocument.Load(strReportPath)
rptDocument.SetDatabaseLogon("admin", "ehvgem")
rptDocument.SetDataSource(DS.Tables(0))
[B]'this should get the subreport filled with data [B]rptDocument.OpenSubreport("subreport2.rpt").SetDataSource(DS.Tables(0))[/B][/B]
rptViewer.ShowRefreshButton = False
rptViewer.ShowCloseButton = False
rptViewer.ShowGroupTreeButton = False
rptViewer.ReportSource = rptDocument
It keeps telling me this:
Object reference not set to an instance of an object.
and that i should use this "Use the New keyword to create the instance. "
The thing is that the sub report should be a copy of the main report.
Thanks in advance