In my project there are two datatables dtNames
and dtDetails
.
I dont know about SQL. Here I am connecting to XML and Textfiles.
dtNames
EmpName EmpRole
a 2
b 3
c 4
dtDetails
Empid EmpName EmpCity EmpRole
101 a abc 3 //EmpRole not equal to above table EmpRole
102 b abc 3
103 c xyz 4
104 d pqr 5
105 e rst 6
I want to relate these two datatables based on the EmpName
and EmpRole
(here comparing to dtNames
) and store the result in a DataSet dsMain
(table from dtDetails
) and then divide the two datatables in according to comparison like matchedDataTable
and unmatchedDataTable
.
I know this can be done using DataRelation or RowFilter but i cant get a thought how to do this because there are two columns to be compared with other datatable two columns which i dont know.(I am beginner in .net)
I tried the below code: (not working)
DataSet dsMain = new DataSet();
DataRelation newRelation = new DataRelation("processData"
, dtNames.Columns["EmpName"], dtDetails.Columns["EmpName"]);
dsMain.Relations.Add(newRelation);
As you can see In the above code I am just comparing one column with other column. How compare with two. I am very close
please assist.