Click here to Skip to main content
15,944,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

I am Generating report on Employee Details.
In this I want to display some of employee details from another table in Subreport.
I can able to display Main Report but not the Subreport.

I also Linked Both Reports with Empcode.

Please Give me a solution i am trying this from last one week.

itried with below code but its not working for me.

I am Trying Below Code ::

Dim SubRptO As CrystalDecisions.CrystalReports.Engine.SubreportObject
Dim SubRptD As New CrystalDecisions.CrystalReports.Engine.ReportDocument

Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo

Dim Constring As String = Convert.ToString(clsCommon.con.ConnectionString)

Dim Connection1 As String() = Constring.Split(";")
Dim ConnDatabase As String = Connection1(1).Remove(0, 17)
Dim ConnDatasource As String = Connection1(0).Remove(0, 12)

ConInfo.ConnectionInfo.ServerName = ConnDatasource
ConInfo.ConnectionInfo.DatabaseName = ConnDatabase
ConInfo.ConnectionInfo.IntegratedSecurity = True

For index = 0 To rpt.ReportDefinition.Sections.Count - 1
                For intCounter = 0 To rpt.ReportDefinition.Sections(index).ReportObjects.Count - 1
                    With rpt.ReportDefinition.Sections(index)
                        If .ReportObjects(intCounter).Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
                            SubRptO = CType(.ReportObjects(intCounter), CrystalDecisions.CrystalReports.Engine.SubreportObject)
                            SubRptD = (SubRptO.OpenSubreport(SubRptO.SubreportName))
                            If (SubRptO.SubreportName = "sbrAccessGroup") Then
                            End If
                            For intCounter1 = 0 To SubRptD.Database.Tables.Count - 1
                        End If
                    End With


            CrystalReportViewer1.ReportSource = rpt

   Dim RowCount As Integer = DsRep.Rows.Count
            If RowCount = 0 Then
                MessageBox.Show("No Records Found !", "ACCESS CONTROL SYSTEM", MessageBoxButtons.OK, MessageBoxIcon.Information)
                '   rpt = Nothing
            End If
            CrystalReportViewer1.ReportSource = Nothing
            CrystalReportViewer1.ReportSource = rpt
Updated 30-Jul-11 0:57am
walterhevedeich 30-Jul-11 7:52am    
When you said its not working, did it throw an error message?

1 solution

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900