Copy specific columns from one DataTable to another

You can simply do it by using DataView.ToTable() :

System.Data.DataView view = new System.Data.DataView(yourOriginalTable);
System.Data.DataTable selected = 
        view.ToTable("Selected", false, "col1", "col2", "col6", "col7", "col3");

Copy the whole table and remove the columns you don't want.

DataTable copyDataTable;
copyDataTable = table.Copy();
copyDataTable.Columns.Remove("ColB");

or

int columnIndex = 1;//this will remove the second column
DataTable copyDataTable;
copyDataTable = table.Copy();
copyDataTable.Columns.RemoveAt(columnIndex);

Tags:

C#

.Net

Datatable