I am not sure if I get your intentions right, but just for compering rows from one datatable to another on certain column you could try this:
private void compareDataTables()
{
// I assume that datatables are of same length
for(int i = 0; i < excelDataTable.Rows.Count; i++)
{
// Assuming that given columns in both datatables are of same type
if(excelDataTable.Rows[i]["col_name"] == sqlDataTable.Rows[i]["col_name"])
{
//your code
}
}
Printing column names:
string names = "Excel table: \n";
foreach (DataColumn dc in excelDataTable.Columns)
{
names += dc.ColumnName+"\n";
}
names += "Sql table: \n";
foreach (DataColumn dc in sqlDataTable.Columns)
{
names += dc.ColumnName+"\n";
}
MessageBox.Show(names);