Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > How to compare 2 rows ieach from 2 different tables in c#
 

How to compare 2 rows ieach from 2 different tables in c#

hi i want to compare values of 2 rows from 2 tables
iam having 2 tables iam able to get the rows from each table to compare
like

Datarow originalRow = daset.table1.rows.find(primarykey);
Datarow tempRow = daset.table2.rows.find(primarykey);

now i want to compare values of originalrow == tempRow

how to do this
iam using itemarray of these rows and looping through each value is their a better way of doing this
thanks


chaitu2  Tuesday, April 22, 2008 4:54 AM

Hi,

Try this :

Code Snippet
DataRow dr = null;
foreach (DataRow dr1 in dTable1.rows)
{
dr = dTable2.Rows.Find(dr1["primarykey"]);
if (dr== null)
{
// do something
}
else
{
// do something
}
}


HTH,
Suprotim Agarwal
Suprotim Agarwal  Tuesday, April 22, 2008 5:08 AM
Asif Shaikh  Tuesday, April 22, 2008 5:05 AM

Hi,

Try this :

Code Snippet
DataRow dr = null;
foreach (DataRow dr1 in dTable1.rows)
{
dr = dTable2.Rows.Find(dr1["primarykey"]);
if (dr== null)
{
// do something
}
else
{
// do something
}
}


HTH,
Suprotim Agarwal
Suprotim Agarwal  Tuesday, April 22, 2008 5:08 AM
hi agarwal thanks for ur reply i got dr1 and dr
i.e i got the 2 rows.... i want to compare dr1 column value w.r.t dr row column value

how to compare dr1 &dr
thanks
chaitu2  Tuesday, April 22, 2008 2:29 PM

You can use google to search for other answers

Custom Search

More Threads

• DataGridComboboxcolumn with different value each row
• Function for insert statement
• Datagridview vs net 2005 - displayindex of columns.
• VS2008 VC++ unable to add an existing data source
• Inserting rows when part of key is filled by DB trigger
• Limit bound fields in custom databound business object.
• get recordsets from underlying BINDINGSOURCE
• SqlDataSource FilterExpression
• Save DataTable to dbf file
• how to verify empty datagrid?