1 Reply Latest reply: Feb 12, 2009 5:27 PM by Ludek Uher RSS

vb.net fails to load subreport with error "The report has no tables"

Mark Marcellus
Currently Being Moderated

We have encountered sporadic problems loading subreports in a vb.net application.  The application is set up to use both trusted and non trusted connections based upon a configuration setting.  For trusted connections the subreports always load properly, for non trusted connections they do not (though the main report loads with no problem).  All of the datasets for the reports are SQL select statements whose fields match the fields in the report.  The reports (main report and subreports) use a SQL commands as the dataset.  Sample code for one of the reports is below.  The code always fails on the .Subreports(u201Cxxu201D).SetDataSource statement (though sometimes the first subreport be successful and the second will fail).



We are using:


Microsoft Visual Studio 2005 Version 8.0.50727.762  (SP.050727-7600)

Microsoft .NET Framework Version 2.0.50727 SP1

Microsoft Visual Studio 2005 Professional Edition - ENU Service Pack 1


We are experiencing the problem on various versions of Windows but I am currently testing on Windows XP Professional Version 2002 SP3.


The report is being created with Crystal (we cannot upgrade from Crystal 10 without application changes and extensive QA).


Any suggestions are appreciated, this is a critical problem for us. 


Sample code:


Public Function PrintFaceSheet(ByVal Filename As String, ByVal MainTable As DataTable, ByVal SubTable As DataTable, ByVal SubTableMeds As DataTable, Optional ByVal Preview As Boolean = False, Optional ByRef ADO As NDSI.ADO.Connection = Nothing) As Boolean




            Dim mobjReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument


            If System.IO.File.Exists(Filename) Then



                With mobjReport


                    If ADO IsNot Nothing Then

                        Dim ldscConnections As CrystalDecisions.Shared.DataSourceConnections = .DataSourceConnections

                        Dim lconInfo As CrystalDecisions.Shared.IConnectionInfo = ldscConnections(0)

                        lconInfo.SetConnection(ADO.Server, ADO.Database, ADO.Trusted)

                        If Not ADO.Trusted Then

                            lconInfo.SetLogon(ADO.Username, ADO.Password)


                            lconInfo.SetLogon("", "")

                        End If

                    End If





                    'MDM 12/23/08: Client medications added to Clinical face sheet


                    '   .VerifyDatabase()

                    'Use Built-In Preview Window

                    If Preview Then

                        Dim lfrm As New NDSI.Reporting.PreviewWindow

                        With lfrm

                            .Viewer.ReportSource = mobjReport



                        End With


                        .PrintToPrinter(1, True, 1, 0)

                    End If


                    Return True


                End With



                '2008.06.19 - VBL - Added log record on error

                ADO.AddToLog(NDSI.ADO.Connection.LogTypeEnum.Problem, "Missing report", "Report " & Filename & " does not exist.  Please check the path and try again.")

            End If


        Catch ex As Exception

            '2008.06.19 - VBL - Added log record on error

            ADO.AddToLog(NDSI.ADO.Connection.LogTypeEnum.Problem, "Report Error", ex.Message)


            Return False


        End Try


    End Function




  • Re: vb.net fails to load subreport with error "The report has no tables"
    Ludek Uher
    Currently Being Moderated

    A bit of clarification needed first. I note that you are using CR 10 to create the report, but I am not sure what version are the CR assemblies used in the report. I suspect you are using the version of Cr that bundled with .NET 2005. Your assemblies would then be version 10.2.3600 - but please do confirm.


    Next, I am not sure about what error is thrown. You mention that the "The code always fails", but what is the error?


    The above is for completness in case my troubleshooting idea below does not pan out.


    If possible, use a report that has one subreport - just simplifies the troubleshooting. Since you are passing ADO .NET datasets to the report, I'd like you to write the dataset(s) to XML as:


    myDataset.WriteXml(xmlPath, XmlWriteMode.WriteSchema)


    Do this just before you pass the dataset to the subreport:


    myDataset.WriteXml(xmlPath, XmlWriteMode.WriteSchema)



    Now, open the report in the CR designer. Go to the design view of the subreport. Go to the Database menu and select "Set Datasource Location".

    In the "Replace with" pane, choose ADO .NET (XML) driver and point to the above created xml. Click on the <Update> button. What happens here? Do you get and error? A field mapping dialog? Does the report and subreport work?