Hello.. i have two datatables with only one column each. i wanted to compare those two columns in two datatables. here is the example

dt1
apple
orange
peach
banana

dt2
apple
peach
mango
apricot
now i want to compare dt2 with dt1. dt2 is bound to a list box. so once i match with dt1, the unmatched items selection should be diabled. here i wanted the mango and apricot selection to be disabled..

hope i am clear.

SELECT * FROM dt2 WHERE dt2.columnname not in (SELECT * from dt1)

This will get you a list of what isn't in dt1 and is in dt2. Of course you'll have to change 'columnname' to whatever you called the column.

I am not using SQL, i wanted to achieve this in C#.. Is there a way where i can implement the above statement in C#?

can anyone help me in this?? i am using WPF and C#.Net..

use LINQ if you are coding under with C# 3 and or .NET. Its a very powerful language feature, with support for quering objects and memory. so you can just do simple queries from you DB o your app with SELECT * FROM ..., then fill them in their respective collections then you can use LINQ to manage and compare them very easly. if that sounds simpler to you.

Happy coding
Cheer