How to append one DataTable to another DataTable

后端 未结 6 1082
臣服心动
臣服心动 2020-12-10 09:59

I would like to append one DataTable to another DataTable. I see the DataTable class has two methods; \"Load(IDataReader)\" and \"Merge(DataTable)\". From the documentation

6条回答
  •  忘掉有多难
    2020-12-10 10:54

    use loop

      for (int i = 0; i < dt1.Rows.Count; i++)
            {      
               dt2.Rows.Add(dt1.Rows[i][0], dt1.Rows[i][1], ...);//you have to insert all Columns...
            }
    

提交回复
热议问题