title: How do I define a DataRelation between a DataSet's DataTables on multiple columns?
body: <p>In my project there are two datatables <code>dtNames</code> and <code>dtDetails</code>.</p>
  
  <p>I dont know about SQL. Here I am connecting to XML and Textfiles.</p>
  
  <p><strong>dtNames</strong></p>
  
  <pre><code>EmpName    EmpRole
  
     a         2
     b         3
     c         4
  </code></pre>
  
  <p><strong>dtDetails</strong></p>
  
  <pre><code> 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
  </code></pre>
  
  <p>I want to relate these two datatables based on the <code>EmpName</code> and <code>EmpRole</code> (here comparing to <code>dtNames</code>) and store the result in a DataSet <code>dsMain</code>(table from <code>dtDetails</code>) and then divide the two datatables in according to comparison like <code>matchedDataTable</code> and <code>unmatchedDataTable</code>.</p>
  
  <p>I know this can be done using <a href="https://stackoverflow.com/q/1014906/1577396">DataRelation</a> or <a href="https://stackoverflow.com/q/6007872/1577396">RowFilter</a> 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)</p>
  
  <p>I tried the below code: (<em>not working</em>)</p>
  
  <pre><code>            DataSet dsMain = new DataSet();
              DataRelation newRelation = new DataRelation("processData"
                  , dtNames.Columns["EmpName"], dtDetails.Columns["EmpName"]);
              dsMain.Relations.Add(newRelation);
  </code></pre>
  
  <p>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</p>
  
  <p>please assist.</p>