Sivajihero Hero

Sivajihero Hero

  • NA
  • 105
  • 30.7k

Crystal report is displaying data with repeated rows

Feb 14 2016 1:09 AM
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. Here is my code
 
 
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();
}
}

Answers (2)