Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am using the following code to check the common message Ids of 3 excel sheets columns

C#
i = 2;
foreach (DataRow row in lstDS[2].Tables[0].Rows)
{


    string fieldFromDB = row[1].ToString();
    string FromDB = row[2].ToString();

    foreach (DataRow row1 in lstDS[0].Tables[0].Rows)
    {
        string fieldFromDB1 = row1[1].ToString();

        if (fieldFromDB == fieldFromDB1)
        {

            foreach (DataRow row2 in lstDS[1].Tables[0].Rows)
            {
                string fieldFromDB2 = row2[1].ToString();

                if (fieldFromDB1 == fieldFromDB2)
                {
                    //commonMsgId = fieldFromDB;

                    xlWorkSheet4.Cells[i, 1] = row[1];
                    xlWorkSheet4.Cells[i, 2] = row[13];
                    xlWorkSheet4.Cells[i, 3] = row1[13];
                    xlWorkSheet4.Cells[i, 4] = row2[13];
                    xlWorkSheet4.Cells[i, 5] = 10.ToString();
                    i++;

                }



            }
        }
    }
}

This code is working fine

Now I need to check the columns of 2 excel sheets for the common message Id and from those I need to eliminate common message Id of 3 excel sheet columns

I am trying something like this in the following code, but this includes the common message Ids of the 3 excel sheets also

C#
i = 2;
foreach (DataRow row in lstDS[2].Tables[0].Rows)
{


    string fieldFromDB = row[1].ToString();
    string FromDB = row[2].ToString();

    foreach (DataRow row1 in lstDS[0].Tables[0].Rows)
    {
        string fieldFromDB1 = row1[1].ToString();

        if (fieldFromDB == fieldFromDB1)
        {

           //do something
        }

    }
}


How can I exclude the common message Ids of 3 excel sheets from this code snippet

Thanks
John
Posted
Updated 15-Dec-13 10:06am
v4
Comments
Richard MacCutchan 15-Dec-13 12:51pm    
Please use the "code" button above the edit box, to add <pre> tags round your code, as I have done on your behalf.
CHill60 15-Dec-13 16:07pm    
... and I've just put back in after they were removed again :-)
Richard MacCutchan 16-Dec-13 3:07am    
Thanks. One wonders what some people actually see after they have pressed the submit or update buttons.
Member 10408451 15-Dec-13 13:21pm    
Hi,

Yes I use tags round my code
Richard MacCutchan 15-Dec-13 13:31pm    
You used the <code> tags, which do not give syntax highlighting.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900