I have a DataTable with this structure:
DataTable1
NAME | SURNAME
Joe | Doe
John | Smith
and another table with this structure:
DataTable2
StudentName| StudentSurname | Status
Joe | Doe | OK
John | Smith | OK
I need to copy all the rows from DataTable1 to DataTable2, following this rule:
- Data found in column NAME -> COPY ALL DATA TO Column StudentName
- Data found in column SURNAME-> COPY ALL DATA TO Column StudentSurname
- Always write OK in column Status.
What is the best way to achieve this?
EDIT: SO far I tried to do this:
foreach (DataColumn dc in DataTable1.Columns)
{
if (DataTable1.Contains("NAME"))
{
//how can I copy it??
}
}
I'm using C#.