cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal report is displaying data with repeated rows while joining multiple tables

Former Member
0 Kudos

In my application I need to print the result in crystal report. The data is with three tables and I have written query for joining them. I have tested the query in sql and it is working sucessfully and displaying the correct result. But when I execute it in crystal report it shows many rows, it shows repeated rows. It only happening in crystal report. I have also done linking the column values in crystal report. Then also the same problem. The crystal report will display many rows as the result which contain many rows that are repeating. I have created the application in asp.net and back end sql.

protected void Page_Load(object sender, EventArgs e)

    {

        DataTable dt = new DataTable();

String str = "select * from Table2 inner join Table1 on Table1.NUM=Table2.NUM and Table1.Branch=Table2.Branch inner join Table3 on Table3.CODE=Table2.CODE where (Table2.NUM=@search)and (Table2.Branch=@search1);";

   

        SqlCommand xp = new SqlCommand(str, con);

        xp.Parameters.Add("@search", SqlDbType.VarChar).Value = TextBox1.Text;

        xp.Parameters.Add("@search1", SqlDbType.VarChar).Value = TextBox2.Text;

        con.Open();

        SqlDataAdapter da = new SqlDataAdapter();

        da.SelectCommand = xp;

        da.Fill(dt);

        con.Close();

        if (dt.Rows.Count > 0)

        {

            ReportDocument crystalReport = new ReportDocument();

            crystalReport.Load(Server.MapPath("invrpt.rpt"));

            crystalReport.SetDatabaseLogon("xx", "xxxxxx");

            crystalReport.SetDataSource(dt);

            CrystalReportViewer1.ReportSource = crystalReport;

            CrystalReportViewer1.DataBind();

        } 

    }

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sivaji, Normally records are duplicated when the linking is wrong, In your case try using the option Select Distinct in SQL


Solutions:

1. Check linking in report why it is producing duplicate records (Database Expert > Links)

2. Create a group on the Unique field and suppress the details section.