There are a bunch of ways but the first one is to sort the first one it's PK
field (you can create a Dataview on it) by using DataView dv =
DataSetName.Tables[TableIndex].DefaultView;
After it's sorted, walk through it and load the distinct values in an
ArrayList for instance so that you only have one instance of each uniquer
value.
http://support.microsoft.com/default.aspx?scid=kb;en-us;326176 Now,
assume that you have the arraylist and that all the values are uinque.
Create A dataview on the second table (for simplicity I'm going to assume
that the PK value is an int). Walk throught the array list and at each
pass, set the rowfilter of the Second table (it doesn't mattter which
dataset it's in b/c you are using a View with both tables) to the PK of
listed inthe arraylist. If the value is there, you'll have only the
matching rows. If you want to see if they exist, you can simply iterate the
view (which will only have matching rows ) and you can use dv2.Count (which
will tell you how many matches you have on the PK, or you can walk through
each value of the second view and compare item by item to the first view's
rows.
http://www.knowdotnet.com/articles/iteratingdataview.html
bool RowsMissing = false;
for(int i = 0; i < myArrayListCount; i++){
dv2.RowFilter = "PKField = '" + (int)myArrayListCount
+ "'";
if(dv2.Count == 0){RowsMissing = true;
//you can exit function or whatever b/c you know they dont'
match
}
Or, you can set the rowsfilter of both views. Then you can do a foreach on
the columns and rows, and at each pass check for equality, if they aren't
the same, then signal a difference and exit or wahtever. If you want to
list the changes you mayneed to create a collection of some sort to hold the
values and positions..not sure what the end game is here
Also, you can definitely use Select statements on DataTable objects and
between the DataView (which is only one line to create and very easy to use)
and DataTable objects, you can do some very fancy searching and filtering.
If you look through my Efficient Using ADO.NET xxxx
http://www.knowdotnet.com/williamryan.html series here and/or look for
..Expression in the search box, you'll find a lot of techniques (both simple
and complex) for searching and finding.
HTH,
Bill
--
W.G. Ryan MVP Windows - Embedded
www.devbuzz.com
www.knowdotnet.com
http://www.msmvps.com/williamryan/