locked
problem in binding crystal report to dataset RRS feed

  • Question

  • User-1179651949 posted

    hi guys,

    i want to bind crstal report to dataset

    HERE IS MY CODE

      Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            Dim con As New SqlConnection("data source=server;initial catalog=Test1;User Id=sa; Password=india123;")
            Dim cmd As New SqlCommand("select firsN,lastN,contNum,gender,city from StudentVB where gender ='female'", con)
            Dim adp As New SqlDataAdapter(cmd)
            Dim ds As New DataSet()
            con.Open()
            adp.Fill(ds)
            con.Close()
            Dim CrtDoc As New CrystalReport1
            CrtDoc.Load()
            'CrtDoc.Load("E:\Utility Softwares\Utsav windowForms\PracCrysalReports\PracCrysalReports\ProjectReports\CrystalReport1.rpt")
            CrtDoc.SetDataSource(ds)
            Crvw1.ReportSource = CrtDoc
            
        End Sub

    but it is getting error on ' CrtDoc.SetDataSource(ds)' and that is 'The report has no tables.'

    i've taken crystal report as a blank crystal report

    please help me with this

    Thursday, November 22, 2012 4:37 AM

Answers

All replies

  • User-896803865 posted

    hi

    try this, you miss the DataBind()

    CrtDoc.Load(Server.MapPath(@"ProjectReports\CrystalReport1.rpt"))

    CrtDoc.SetDataSource(ds.Table[0])

    Crvw1.ReportSource=CrtDoc

    Crvw1.DataBind()

    thanx

    Thursday, November 22, 2012 7:10 AM
  • User1253526462 posted

    Hi,

      In your report, there is no table as you have mentioned u have created a blank report  (CrystalReport.rpt).’. So in this case, if you try to set datasource to reportDocument object that referenced to CrystalReport.rpt which is blank report, you will get an error (Line 41: mouradRepDocument.SetDataSource(dataSet);). Because CrystalReport.rpt does not contain any command/Table. As you are trying to show your report dynamically from different database. In this case, you should make your report with all possible columns. Once report ready with all possible columns, you need to manage all these columns in dataset/datatable at time of datasource binding.

    For more info refer the following links.

    http://www.codeproject.com/Questions/331431/The-report-has-not-tables-error-in-csharp

    http://go4answers.webhost4life.com/Example/crystal-report-exception-the-report-no-4545.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 22, 2012 7:15 AM
  • User-1179651949 posted

    Thanks maheshwari.boogu.

    your answar was very helpful to me...

    Monday, November 26, 2012 2:39 AM