Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I created a crystal report with two tables..
My SQL query is -:
SQL
SELECT ct.custID, c.custName, c.custAdd, ct.custTranDate, ct.custTranType, ct.custPaidAmt, ct.custDueAmt, c.custArea
FROM custTransaction AS ct INNER JOIN custDetails AS c ON ct.custID = c.custID
WHERE ct.custTranDate BETWEEN #2/2/13# AND #3/2/13# and ct.custID='CUST-000002';

when i run this query in access it's works fine.. but when i run this query with OLEDB object, and set dataset to crystal report. crystal report show duplicate records(it's multiple of specific custID in custTransaction. if i entry 3 records of custID='CUST-000002' in custTransaction table,it show 3*3 times same records in crystal report).

My C# code is -:
C#
private void button1_Click(object sender, EventArgs e)
        {
            OleDbDataAdapter adpt=new OleDbDataAdapter("SELECT ct.custID, c.custName, c.custAdd,ct.custTranDate,ct.custTranType,ct.custPaidAmt,ct.custDueAmt, c.custArea FROM custTransaction ct INNER JOIN custDetails c ON ct.custID = c.custID WHERE ct.custTranDate BETWEEN #"+MF.retOriginalDate(DTP1.Value.Date.ToShortDateString())+"# AND #"+MF.retOriginalDate(DTP2.Value.Date.ToShortDateString())+"# and ct.custID='"+textBox3.Text+"'",conn);
            DataSet ds = new DataSet();
            adpt.Fill(ds, "custTransaction");
            customerLaser CL = new customerLaser();//customerLaser is a Crystal Report            
            CL.SetDataSource(ds.Tables["custTransaction"]);                        
            customerLaser CL = new customerLaser();
            CL.SetDataSource(DC.dataSet.Tables["custTransaction"]);
            CL.SetDatabaseLogon("Admin", "");
            CL.Refresh();
            report_show RS = new report_show();
            RS.crystalReportViewer1.ReportSource = CL;
            RS.crystalReportViewer1.Refresh();
            RS.Show();
        }

I'm using access database....
how to avoid duplicate record in crystal report???
thanks in advance...
Posted
Updated 2-Mar-13 7:18am
v3

Hi!!! Jayanta


use like this query

SQL
<pre lang="SQL">SELECT Customers.CompName, Customers.Add, Customers.City, Customers.ContactName, Customers.Phone
FROM Customers
WHERE (((Customers.CompName) In (SELECT [CompName] FROM [Customers] As Tmp GROUP BY [CompName],[Add],[City] HAVING
Count(*)>1 And [Add] = [Customers].[Add] And [City] = [Customers].[City])))
ORDER BY Customers.CompName, Customers.Add, Customers.City;



ref:: http://office.microsoft.com/en-in/access-help/find-eliminate-or-hide-duplicate-records-in-access-HA001034558.aspx[^]
 
Share this answer
 
v2
Comments
JayantaChatterjee 5-Mar-13 22:07pm    
Sir, I want to get the value from two table based on custID and date..
Your query is base on one table, also I'm using it in C# not MsAccess..
Hi Check the suppress check Box for the field you want to avoid Duplicated entry
 
Share this answer
 

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