Click here to Skip to main content
15,905,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone,

I am working on project of purchase order in asp.net , in that i want crystal reports.

I am working on crystal reports push process.

the problem arising is when i fire the query and bind it to the crystal report, though the record is only one in the dataset it is coming twice in crystal report.

i.e
the data in data set is like this:
Sr.No PurchaseOrderNumber Item
1 PO/MA/2147 Dishes

but in crystal report it is displayed like this:

Sr.No PurchaseOrderNumber Item
1 PO/MA/2147 Dishes
2 PO/MA/2147 Dishes

Please help me out how to solve this, i m really stuck up..


Thanks in advance.

Krunal Panchal

[Update from OP]
protected void btnSubmit_Click(object sender, EventArgs e) 
{ 
   try 
   { 
      cn.Open(); 
      cmd = new SqlCommand("select Distinct Username.Password,UserTasks from User_Master,UserTasks where   
         User_Master.Id=UserTasks.UserId and User_Master.UserId='" + txtUerid.Text.ToString() + "' ", cn); 
      da = new SqlDataAdapter(cmd); 
      ds = new DataSet(); 
      da.Fill(ds); 
      ReportDocument rep = new ReportDocument(); 
      string reportPath = Convert.ToString (Server.MapPath("~/CrystalReport1.rpt")); 
      rep.Load(reportPath); 
      rep.SetDataSource(ds.Tables[0]); 
      CrystalReportViewer1.ReportSource=rep; 
   } 
   catch { } 
   finally 
   { 
      cn.Close(); 
   } 
}

This is my function for binding data to crystal report.. Please help me out..
Posted
Updated 15-Jul-11 0:37am
v2
Comments
walterhevedeich 15-Jul-11 4:15am    
Perhaps showing your code where you bind your dataset to your report will help us to help you.
[no name] 15-Jul-11 6:25am    
protected void btnSubmit_Click(object sender, EventArgs e)
{
try {
cn.Open();
cmd = new SqlCommand("select Distinct Username.Password,UserTasks from User_Master,UserTasks where User_Master.Id=UserTasks.UserId and User_Master.UserId='" + txtUerid.Text.ToString() + "' ", cn);
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
ReportDocument rep = new ReportDocument();
string reportPath = Convert.ToString (Server.MapPath("~/CrystalReport1.rpt"));
rep.Load(reportPath);
rep.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource=rep;
}
catch { }
finally { cn.Close(); }
}

This is my function for binding data to crystal report..

Please help me out..
J.Karthick 15-Jul-11 9:08am    
Have you got solution for that???

Actually, me too having same problem in same purchase report....When i bind my datatable it says "LOAD REPORT FAILED"

Please post snipets of your code and query for more elaboration.
At first it may be problem of joins you are using in your query. Try Distinct KeyWord if you are using SQL server
 
Share this answer
 
Comments
[no name] 15-Jul-11 6:26am    
protected void btnSubmit_Click(object sender, EventArgs e)
{
try {
cn.Open();
cmd = new SqlCommand("select Distinct Username.Password,UserTasks from User_Master,UserTasks where User_Master.Id=UserTasks.UserId and User_Master.UserId='" + txtUerid.Text.ToString() + "' ", cn);
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
ReportDocument rep = new ReportDocument();
string reportPath = Convert.ToString (Server.MapPath("~/CrystalReport1.rpt"));
rep.Load(reportPath);
rep.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource=rep;
}
catch { }
finally { cn.Close(); }
}

This is my function for binding data to crystal report..

Please help me out..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900