Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I have written a code to display some data in a DataGridView. but it shows duplicate values. here is the code,

C#
public void showEvents()
        {
            cmd2 = new MySqlCommand();
            String cmdString2 = "SELECT d.DId, d.Date,d.Time,d.Temp, d.DLane, d.DVentilation, d.DRemarks FROM date d, container c, Plugoff p where c.GKId=d.GKId  AND c.ContainerNo like ('" + txtContNo.Text + "%') AND c.GKId = ('" + txtUsed.Text + "') ";
            adp = new MySqlDataAdapter(cmdString2, con);
            ds = new DataSet();
            adp.Fill(ds, "cont");
            dataGridView1.DataSource = ds.Tables["cont"];
        }


please someone show me the issue soon ???
Posted
Comments
Sandeep Mewara 21-Apr-12 11:42am    
Q: You sure that the query is returning correct set of result?

1 solution

You are joining three tables but you where clause contains only one join between them.
Remove Plugoff p from your query and try again. I don't think you are using any values from it anywhere as it is anyway.
 
Share this answer
 
v2
Comments
kasun.s 21-Apr-12 21:48pm    
Thanks a lot Abhinav, It was the issue. Thanks again !
Abhinav S 21-Apr-12 22:41pm    
You are welcome. Vote if it helped.
VJ Reddy 23-Apr-12 19:44pm    
Good answer. 5!
Abhinav S 23-Apr-12 23:17pm    
Thank you VJ.
Monjurul Habib 27-Apr-12 3:15am    
5!

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