I would like to compare columns of 2 data table.
my 1st data table:
| app_ID | int | True | AppID | Both | |
| app_Name | varchar | True | AppName | Both | |
| app_Adress | varchar | True | AppAddress | Both | |
| app_Lattitude | varbinary | True | AppLatitude | Both | |
| app_Longitude | varbinary | True | AppLongitude | Both | |
| app_Gender | char | false | |||
| app_IsApplicationCorrect | bit | false |
and my 2nd table:
| app_ID | int | |
| app_Salutation | varchar | |
| app_Name | varchar | |
| app_Adress | varchar | |
| app_Lattitude | varbinary | |
| app_Longitude | varbinary | |
| app_Gender | char | |
| app_IsApplicationCorrect | bit | |
| app_IsWorkingProper | bit |
i want to compare 1st and 2nd tables 1st column and check for new data if available and add the data from 1st table to 2nd table...
OUT PUT should be:
| app_ID | int | True | AppID | Both |
| app_Salutation | varchar | false | ||
| app_Name | varchar | True | AppName | Both |
| app_Adress | varchar | True | AppAddress | Both |
| app_Lattitude | varbinary | True | AppLatitude | Both |
| app_Longitude | varbinary | True | AppLongitude | Both |
| app_Gender | char | false | ||
| app_IsApplicationCorrect | bit | false | ||
| app_IsWorkingProper | bit | false |

Vasanth Krishnan102 reputationPosted Sep 1, 2014, 10:21 PM EDT
Raghavendra Joshi30 reputationPosted Sep 1, 2014, 10:55 PM EDT
Vasanth Krishnan102 reputationPosted Sep 1, 2014, 11:14 PM EDT
StringCollection lsttable1ColumnValues = new StringCollection();
StringCollection lsttable2ColumnValues = new StringCollection();
Add that particular column values to the list
//Add the table 1 value in the list
foreach (DataRow drTable1 in dtTable1.Rows)
{
lsttable1ColumnValues.Add(drTable1["Column1"].ToString());
}
foreach (DataRow drTable1 in dtTable1.Rows)
{
lsttable2ColumnValues.Add(drTable1["Column1"].ToString());
}
Now u can compare the list that are common in the two list and achieve what u want.
Thanks
Mohammad Imran155 reputationPosted Sep 9, 2014, 11:05 PM EDT