Wednesday, 28 August 2013

Check if a data row of a data table is contained in another datatable

Check if a data row of a data table is contained in another datatable

I have a dataset DS which contains one data table and the data table has
several datarows.
I have another data set DS1 which contains one datatable and the datatable
has one datarow.
I would like to check if DS contains the row in DS1
The DataRow is of the following format :
Id Description
Currently I am doing the following :
if (!(ds.Tables[0].Rows.Contains(ds1.Tables[0].Rows[0])))
It throws an error like :
.Data.MissingPrimaryKeyException: Table doesn't have a primary key.
Is there any other way to do it ?
For example
Dataset DS contains a Datatable :
1 ABC
2 DEF
3 GHI
Dataset DS1 contains a datatable :
1 ABC
I would like to see if the Row in datatable of DS1 is contained in the row
of a datatable in DS

No comments:

Post a Comment