locked
Error: "The report has no tables." when setting datasource for Crystal Report RRS feed

  • Question

  • I am creating a web application in ASP.NET 2.0 using Visual Studio .NET 2005.  I tried to set data source for ReportDocument to a dataset, but got an error saying that "The report has no tables." on the line that set the data source.  I tried using dataset or datatable and got the same result.  I checked the dataset and I could view data in the dataset.  What have I done wrong?  Any help is appreciated.

    Below are my codes in .aspx and .aspx.vb.

    .aspx

    ==============================================================

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="BatchCoverPage.aspx.vb" Inherits="BatchCoverPage" %>

    <%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"

    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >

         <head runat="server">

         <title>Untitled Page</title>

         <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"

    rel="stylesheet" type="text/css" />

    </head>

    <body>

         <form id="form1" runat="server">

              <div>

                   <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="False" Height="1231px" Width="789px" HasCrystalLogo="False" />

              </div>

         </form>

    </body>

    </html>

    =======================================================================

    .aspx.vb

    *****************************************************************************************************************

    Imports System.IO

    Imports System.Data

    Imports System.Data.SqlClient

    Imports CrystalDecisions.CrystalReports.Engine

    Imports CrystalDecisions.Shared

    Partial Class BatchCoverPage

         Inherits System.Web.UI.Page

         Private Sub ConfigureCrystalReports(ByVal sender As Object, ByVal e As System.EventArgs)

              Dim rptBatchCoverPage As ReportDocument = New ReportDocument()

              Dim strReportPathFile As String

              Dim conCFSP As SqlConnection

              Dim daCFSP As SqlDataAdapter

              Dim dsCFSP As DataSet

              Dim dtCFSP As DataTable

              conCFSP = New SqlConnection

              conCFSP.ConnectionString = "Data Source=myserver;Initial Catalog=db;User ID=Users;Password=Password"

              conCFSP.Open()

              daCFSP = New SqlDataAdapter()

              daCFSP.SelectCommand = New SqlCommand(CStr(Session("strSQL")), conCFSP)

              dsCFSP = New DataSet

              daCFSP.Fill(dsCFSP, "tblList")

              dtCFSP = New DataTable

              dtCFSP = dsCFSP.Tables("tblList")

              strReportPathFile = Server.MapPath("/CFSP" & "\Reports\crBatchCoverPage.rpt")

              rptBatchCoverPage.Load(strReportPathFile, OpenReportMethod.OpenReportByTempCopy)

              rptBatchCoverPage.SetDataSource(dsCFSP)

              '     rptBatchCoverPage.SetDataSource(dtCFSP)

             CrystalReportViewer1.ReportSource = rptBatchCoverPage

              ViewPDF(sender, e, rptBatchCoverPage)

         End Sub

         Private Sub ViewPDF(ByVal sender As System.Object, ByVal e As System.EventArgs, ByVal rptBatchCoverPage As ReportDocument)

              Dim oStreamPDF As MemoryStream

              oStreamPDF = CType(rptBatchCoverPage.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat), MemoryStream)

              Response.Clear()

              Response.Buffer = True

              Response.ContentType = "application/pdf"

              Response.BinaryWrite(oStreamPDF.ToArray())

              Response.End()

         End Sub

         Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

              ConfigureCrystalReports(sender, e)

         End Sub

    End Class

    ***************************************************************************************************************

    Wednesday, April 12, 2006 10:14 PM

Answers

  • I would check how you designed your report.  I would export the dataset to xml with schema, try to update your report to use that as the data connection, then try this again.
    Friday, April 14, 2006 5:58 PM

All replies

  • I would check how you designed your report.  I would export the dataset to xml with schema, try to update your report to use that as the data connection, then try this again.
    Friday, April 14, 2006 5:58 PM
  • Thank you, mewdied.  It works!
    Friday, April 14, 2006 9:26 PM
  •  

    Hi Marlin1,

    I am facing the same problem that you faced in crystal reports..

     

    I am getting the same error "The report has no tables".

     

    I didnt got the solution given by mewdied.

     

    can you just paste those 3-4 lines of code which helped you in getting rid of that error.

     

    Any help will be highly appreciated.

    Tuesday, September 11, 2007 2:25 AM
  • Hi Kapadia,

     

    It has been a while.  Here is a .pdf from Business Objects web site on how to do these things http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf.  Go to page 328 Data Connectivity Tutorials, Connecting to ADO.NET DataSets.

     

    When you add a new item in your project, instead of choosing DataSet, choose XML Schema.  Once in the XML Schema designer, do the following.

    1. Right-click and choose Add | New Element.  Type in the name that you will use to reference this as a data table in the first row.  (I named my XML Schema as dsCFSP and my data table as dtBatchCoverPage.)
    2. Below the first row, you will see * and three blank columns.  Click on the first column.  You will see a dropdown list.  Choose E element or press E in the column.  Add the name that you will use to represent the field in the second column and the data type in the third column.

    In addition, you will need to create a helper class (in my case it is called DataSetConfiguration.vb in App_Code) to populate the data.

     

    Hope this helps.

     

    ===============================================================================

    Below are the codes that I used to populate the data.  They are on the page that accept user's input.

    ===============================================================================

    ' ***** Populate data to the dataset using dataset schema.

    Dim strSchemaFilePath As String = Server.MapPath("~\Datasets\dsCFSP.xsd")

    Dim strDataTableName As String = "dtBatchCoverPage"

    Dim dsCFSP As DataSet = DataSetConfiguration.PopulateDataSetSchema(strSchemaFilePath, GetConnectionString(), strSQL, strDataTableName)

    Dim dtCFSP As DataTable

     

    dtCFSP = dsCFSP.Tables("dtBatchCoverPage")

     

    Session("dtCFSP") = dtCFSP

     

     

    ================================================================================

    Below are the codes in the DatasetConfiguration.vb in App_Code which is used to populate the data.

    ================================================================================

    Option Strict On

     

    Imports System.Data

    Imports System.Data.SqlClient

    Imports Microsoft.VisualBasic

     

    Public Class DataSetConfiguration

     

         Public Shared ReadOnly Property PopulateDataSetSchema(ByVal strSchemaFilePath As String, ByVal strConnectionString As StringByVal strSQL As String, ByVal strDataTableName As String) As DataSet

     

              Get

                   Dim ds As DataSet = New DataSet()

                   ds.ReadXmlSchema(strSchemaFilePath)

                   Dim con As SqlConnection = New SqlConnection(strConnectionString)

                   Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, con)

                   da.Fill(ds, strDataTableName)

                   Return ds

              End Get

     

         End Property

     

    End Class

     

     

    ================================================================================

    Below are the codes on the page that contains the CrystalReportViewer to render the report.

    ================================================================================

    Dim rptBatchCoverPage As ReportDocument = New ReportDocument

    Dim strReportFilePath As String = Server.MapPath("~\Reports\crBatchCoverPage.rpt")

    rptBatchCoverPage.Load(strReportFilePath)

    ' ***** Set data source.

    rptBatchCoverPage.SetDataSource(Session("dtCFSP"))

    ' ***** Bind the report.

    CrystalReportViewer1.ReportSource = rptBatchCoverPage

    Tuesday, September 11, 2007 2:32 PM
  • Create an XML schema first, then execute the program with error.

    Now, Goto @ crystal report at DatabaseFields, find your schema in Create New Connection -->ADO.NET Connection, give your xml schema file path.

    Now your schema is added in your DatabaseFields section. Now Add the fields you want in your project. 

    Run the program, it will not give any error like NO TABLE FOUND...................

    ENJOY............ 
    Friday, May 30, 2008 1:17 PM
  • marlin1 said:

    I am creating a web application in ASP.NET 2.0 using Visual Studio .NET 2005.  I tried to set data source for ReportDocument to a dataset, but got an error saying that "The report has no tables." on the line that set the data source.  I tried using dataset or datatable and got the same result.  I checked the dataset and I could view data in the dataset.  What have I done wrong?  Any help is appreciated.

    Below are my codes in .aspx and .aspx.vb.

    .aspx

    ==============================================================

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="BatchCoverPage.aspx.vb" Inherits="BatchCoverPage" %>

    <%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"

    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >

         <head runat="server">

         <title>Untitled Page</title>

         <link href="/aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer3/css/default.css"

    rel="stylesheet" type="text/css" />

    </head>

    <body>

         <form id="form1" runat="server">

              <div>

                   <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="False" Height="1231px" Width="789px" HasCrystalLogo="False" />

              </div>

         </form>

    </body>

    </html>

    =======================================================================

    .aspx.vb

    *****************************************************************************************************************

    Imports System.IO

    Imports System.Data

    Imports System.Data.SqlClient

    Imports CrystalDecisions.CrystalReports.Engine

    Imports CrystalDecisions.Shared

    Partial Class BatchCoverPage

         Inherits System.Web.UI.Page

         Private Sub ConfigureCrystalReports(ByVal sender As Object, ByVal e As System.EventArgs)

              Dim rptBatchCoverPage As ReportDocument = New ReportDocument()

              Dim strReportPathFile As String

              Dim conCFSP As SqlConnection

              Dim daCFSP As SqlDataAdapter

              Dim dsCFSP As DataSet

              Dim dtCFSP As DataTable

              conCFSP = New SqlConnection

              conCFSP.ConnectionString = "Data Source=myserver;Initial Catalog=db;User ID=Users;Password=Password"

              conCFSP.Open()

              daCFSP = New SqlDataAdapter()

              daCFSP.SelectCommand = New SqlCommand(CStr(Session("strSQL")), conCFSP)

              dsCFSP = New DataSet

              daCFSP.Fill(dsCFSP, "tblList")

              dtCFSP = New DataTable

              dtCFSP = dsCFSP.Tables("tblList")

              strReportPathFile = Server.MapPath("/CFSP" & "\Reports\crBatchCoverPage.rpt")

              rptBatchCoverPage.Load(strReportPathFile, OpenReportMethod.OpenReportByTempCopy)

              rptBatchCoverPage.SetDataSource(dsCFSP)

              '     rptBatchCoverPage.SetDataSource(dtCFSP)

             CrystalReportViewer1.ReportSource = rptBatchCoverPage

              ViewPDF(sender, e, rptBatchCoverPage)

         End Sub

         Private Sub ViewPDF(ByVal sender As System.Object, ByVal e As System.EventArgs, ByVal rptBatchCoverPage As ReportDocument)

              Dim oStreamPDF As MemoryStream

              oStreamPDF = CType(rptBatchCoverPage.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat), MemoryStream)

              Response.Clear()

              Response.Buffer = True

              Response.ContentType = "application/pdf"

              Response.BinaryWrite(oStreamPDF.ToArray())

              Response.End()

         End Sub

         Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

              ConfigureCrystalReports(sender, e)

         End Sub

    End Class

    **************************************************************************************************************

    Create an XML/XML Schema file, before the error came,
    Then Goto Crystal Report--> Databasefields --> CreateNewConnection -->Double Click the ADO.NET Connection--> give the FilePath = YOur XML/XML Schema you created. Now the table is added in your DatabaseFields, add the fields you want in your report & run the application,  Now, no error will come.


    Friday, May 30, 2008 1:23 PM