title: How to loop through the Datatable columns and assign values to it dynamically in vb.net?
body: <p>I am retrieving the values from XML and storing in a datatable after which i will insert the datatable values to the database. </p>
  
  <p>The Database table structure will be same as the datatable structure i have created. </p>
  
  <p>In the below XML i have only 3  nodes (6 values comprising EmpName and EmpID) , so i have to assign these node values to the first six columns of my datatable. Rest of the columns in datatable should be empty. How can i loop through ?</p>
  
  <p>Note : The table structure is fixed to only 15 employee details, which may sound silly, but this is just an example of my scenario and nothing to do with Employee details actually. If the are more than 15  nodes in XML i will have to ignore it.</p>
  
  <p>XML :</p>
  
  <pre><code>&lt;Employee&gt;
      &lt;add&gt; 
        &lt;EmpName&gt;Ronaldo&lt;/EmpName&gt;
        &lt;EmpID&gt;14&lt;/EmpID&gt;
      &lt;/add&gt;
      &lt;add&gt; 
        &lt;EmpName&gt;Messi&lt;/EmpName&gt;
        &lt;EmpID&gt;15&lt;/EmpID&gt;
      &lt;/add&gt;
      &lt;add&gt; 
        &lt;EmpName&gt;David&lt;/EmpName&gt;
        &lt;EmpID&gt;16&lt;/EmpID&gt;
      &lt;/add&gt;
    &lt;/Employee&gt;
  </code></pre>
  
  <p>Datatable :</p>
  
  <pre><code>        dt_FAQ.Columns.Add("Employee_1", GetType(String)) 
          dt_FAQ.Columns.Add("EmpID_1", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_2", GetType(String))
          dt_FAQ.Columns.Add("EmpID_2", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_3", GetType(String))
          dt_FAQ.Columns.Add("EmpID_3", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_4", GetType(String))
          dt_FAQ.Columns.Add("EmpID_4", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_5", GetType(String))
          dt_FAQ.Columns.Add("EmpID_5", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_6", GetType(String))
          dt_FAQ.Columns.Add("EmpID_6", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_7", GetType(String))
          dt_FAQ.Columns.Add("EmpID_7", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_8", GetType(String))
          dt_FAQ.Columns.Add("EmpID_8", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_9", GetType(String))
          dt_FAQ.Columns.Add("EmpID_9", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_10", GetType(String))
          dt_FAQ.Columns.Add("EmpID_10", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_11", GetType(String))
          dt_FAQ.Columns.Add("EmpID_11", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_12", GetType(String))
          dt_FAQ.Columns.Add("EmpID_12", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_13", GetType(String))
          dt_FAQ.Columns.Add("EmpID_13", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_14", GetType(String))
          dt_FAQ.Columns.Add("EmpID_14", GetType(String)) 
          dt_FAQ.Columns.Add("Employee_15", GetType(String))
          dt_FAQ.Columns.Add("EmpID_15", GetType(String))
  </code></pre>