Search code examples
c#asp.netcrystal-reportsdataset

Is that possible to bind two dataset at a same time in crystal report?


Is that possible to bind two dataset at a same time in asp.net crystal report?

I tried the code below, but it asks for server details:

                Invoice inv = new Invoice();
                inv.OrgId = Session["org_id"].ToString();
                inv.InvoiceId = invoiceId.ToString();
                ds = _reportController.ReportPrintBillView(inv);
                dtBill=ds.Tables[0];
                dtInvoice = ds.Tables[1];

                ReportDocument myRpt = new ReportDocument();
                myRpt.Load(Server.MapPath("PrintandprintBill.rpt"));
                myRpt.SetDatabaseLogon("root", "root", "localhost", "hemaepdb");
                myRpt.SetDataSource(dtBill);
                myRpt.SetDataSource(dtInvoice);
                CrystalReportViewerPrint.ReportSource = myRpt;
                CrystalReportViewerPrint.Visible = true;

Solution

  • No, the report accepts one datasource. However your subreports may have a different datasource.

    EDIT:

    If you need data from two different datasets that have similar data you might try to combine the data into one dataset. Even if some of the data duplicates, you can then create groups and use the suppress functionality to only show and format the data in the way you need to see it. See my answer here for a better explanation of the grouping and suppressing that I am referring to.