title: how to loop through each row in datatable and insert data in mySQL
body: <p>I have this code that loops through each row in a datagridview but I don't know what is the equivalent code in using a datatable. I tried using <code>datarow</code> instead of <code>DataGridViewRow</code> but I don't know how to get the data in each row like I did in this code. So how will I get data in each row in datatable?  </p>
  
  <pre><code>using (MySqlCommand cmd = new MySqlCommand(query_1, con))
  {
  foreach (DataGridViewRow dr in dataGridView2.Rows)
  {
  if (Convert.ToInt32(dr.Cells["quantity"].Value) &gt; 0)
  {
  cmd.Parameters.AddWithValue("@product", dr.Cells["product_name"].Value);
  cmd.Parameters.AddWithValue("@variant", dr.Cells["variant_name"].Value);
  cmd.Parameters.AddWithValue("@size", dr.Cells["size"].Value);
  cmd.Parameters.Add("@qty", MySqlDbType.Int32, 8).Value = dr.Cells["quantity"].Value;
  cmd.Parameters.AddWithValue("@ID", txtboxID.Text);
  cmd.ExecuteNonQuery();
  cmd.Parameters.Clear();
  }
  }
  }
  </code></pre>