Unable to Copy datacolumn from one data table to another

后端 未结 6 952
独厮守ぢ
独厮守ぢ 2021-01-17 22:28

How can I copy 1 data column from 1 data table to a new datatable. When I try to do it, I get the error Column \'XXX\' already belongs to another DataTable.?



        
6条回答
  •  無奈伤痛
    2021-01-17 23:24

    You cannot copy a DataColumn. (DataColumns are very tightly coupled with their tables)

    Instead, you can add a new column with the same name and datatype.

    You might be looking for DataTable.Clone(), which will create a structual copy of an entire table. (With the same schema, but no data)

提交回复
热议问题