Error while coping datacolumn with data from one table to another .
- by Harikrishna
I have one Datatable like
DataTable addressAndPhones;
And there are four columns name,address,phoneno,and other details and I only want two columns Name and address from that so I do for that is
DataTable addressAndPhones2;
addressAndPhones2.Columns.Add(new DataColumn(addressAndPhones.Columns["name"].ColumnName));
addressAndPhones2.Columns.Add(new DataColumn(addressAndPhones.Columns["address"].ColumnName));
But it gives me error so how can I copy fix no of columns data from one table to another table ?
ERROR :Object reference not set to an instance of an object.