Table7_ref
| A | B | C | D | E | F | G | H | I | J |
| 1 | 2 | 3 | 4 | 6 | 8 | 9 | 0 | - | 8 |
Table7
| A | B | C | D |
| 13 | 11 | 144 | 12 |
Output
table7_ref
| A | B | C | D |
| 1 | 2 | 3 | 4 |
What is the mistake I am doing
for(int p=0; p
string colxname = table7_ref.Columns[p].ToString();
if (!table7.Columns.Contains(colxname))
{
table7_ref.Columns.Remove(colxname);
}
}

VulpesPosted Jun 5, 2014, 10:10 AM
Try this:
Farhan ShariffPosted Jun 5, 2014, 10:30 AM
VulpesPosted Jun 5, 2014, 10:25 AM
However, you can still ensure that you'll examine all the elements by reducing the control variable by 1 each time you make a removal. So this should also work:
Farhan ShariffPosted Jun 5, 2014, 10:15 AM
Farhan ShariffPosted Jun 5, 2014, 9:52 AM
Khan Abrar AhmedPosted Jun 5, 2014, 9:41 AM
var matched = from table1 in Table7_ref.AsEnumerable()
join table2 in Table7.AsEnumerable() on table1.Field
where table1.Field
Farhan ShariffPosted Jun 5, 2014, 9:33 AM
Khan Abrar AhmedPosted Jun 5, 2014, 9:22 AM
/DataTable Newtable7_ref = new DataTable();
for(int p=0; p
string colxname = table7_ref.Columns[p].ToString();
if (table7.Columns.Contains(colxname))
{
//new table variable and the maching column
Newtable7_ref.Columns.add(colxname);
}
}
after that assign the value
table7_ref =Newtable7_ref;