0

hai, i have two datasets which contains table values.the process is to compare the two datasets (DS1 and DS2) whether its equal or not...help us plz...thanks in advance.

2
Contributors
1
Reply
7
Views
10 Years
Discussion Span
Last Post by nrar
0

Try this.In my ex.both datasets contain one field each.For multiple fields you have to change code a bit.

     foreach (DataRow row in ds.Tables[0].Rows)
    {
        foreach (DataRow row1 in ds1.Tables[0].Rows)
        {
            if (row != row1)
            {
                if (ListBox1.Items.Count == 0)
                {
                    ListBox1.Items.Add(new ListItem(row.ItemArray.GetValue(0).ToString()));
                }
                else
                {
                    for (int i = 0; i < ListBox1.Items.Count; i++)
                    {



                            if (row.ItemArray.GetValue(0).ToString() != ListBox1.Items[i].Value)
                                if (i == ListBox1.Items.Count - 1)
                                { ListBox1.Items.Add(new ListItem(row.ItemArray.GetValue(0).ToString())); }




                    }
                }

            }
        }
    }

Edited by Dani: Formatting fixed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.