Populate Crystal Report using dataset with multiple tables using C# in ASP.Net

Last Reply 2 months ago By dharmendr

Posted 2 months ago


I am trying to populate crysatl report using dataset. I tried the reference from the link. https://www.aspsnippets.com/Articles/Crystal-Report-ASPNet-Example-using-DataSet-or-DataTable-in-C-VBNet-and-Visual-Studio-2010.aspx. But now the issue for me is that i need to show fields of two tables in the CR.

1) I tried combing the two select statements and fill the data, but failed.

2) I cannt use direct database table, as this give me Database Login Issue.

3) I cann't join the two select statement, because the tables dont have a joinning(common field)

Please help me develop a code, through which i can populate data in my crytal report. The report will have fields from two tables.



Posted 2 months ago

Hi delhigle,

For displaying data from multiple table you need to do the following steps.

1. You need to add another datatable to the dataset(.xsd file)

2. Then in Field Explorer Right click on Database Fields -> Database Export.. -> Right click on DataSetname Refresh it.

3. Then add the new table to the Selected Tables section and click ok.

4. Now add the fields to the report as per your requirement.

5. Change the code with the below to display data from multiple table.


protected void Page_Load(object sender, EventArgs e)
    ReportDocument crystalReport = new ReportDocument();
    Customers dsCustomers = GetData("select * from customers GO select EmployeeID,FirstName,City,Country from Employees");
    CrystalReportViewer1.ReportSource = crystalReport;

private Customers GetData(string query)
    string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
    SqlCommand cmd = new SqlCommand(query);
    using (SqlConnection con = new SqlConnection(conString))
        using (SqlDataAdapter sda = new SqlDataAdapter())
            cmd.Connection = con;

            sda.SelectCommand = cmd;
            using (Customers dsCustomers = new Customers())
                return dsCustomers;


I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html