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);
}
}

VulpesRank #55 · 29.2K reputationPosted Jun 5, 2014, 6:10 AM EDT
Try this:
VulpesRank #55 · 29.2K reputationPosted Jun 5, 2014, 6:25 AM EDT
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:
Khan Abrar AhmedRank #778 · 3K reputationPosted Jun 5, 2014, 5:22 AM EDT
/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;
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 5, 2014, 5:33 AM EDT
Khan Abrar AhmedRank #778 · 3K reputationPosted Jun 5, 2014, 5:41 AM EDT
var matched = from table1 in Table7_ref.AsEnumerable()
join table2 in Table7.AsEnumerable() on table1.Field
where table1.Field
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 5, 2014, 5:52 AM EDT
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 5, 2014, 6:15 AM EDT
Farhan ShariffRank #2,004 · 725 reputationPosted Jun 5, 2014, 6:30 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts