|
-
Jul 26th, 2007, 01:06 AM
#1
Thread Starter
New Member
DataTable Comparision
Hello All,
I am working in C#.NET 2.0
I need to Compare two databases, in which one is of Oracle Database and another is of SQL Server 2000 database. I want to delete records from SQL Serever which are not in Oracle database.
I created two datatables - SQLdt and ORAdt,I did upto filling these two datatables using Query but i dont know how to compare two datatables.
Can anyone help me to solve this?
-
Jul 26th, 2007, 01:29 AM
#2
Re: DataTable Comparision
How are you identifying that rows are the same? Must they have all fields match? ...just an ID? ...some other field or fields?
-
Jul 26th, 2007, 01:42 AM
#3
Thread Starter
New Member
Re: DataTable Comparision
Thank you for yr reply...
I have a common field - ID - in both DataTables but i dont know how to compare two rows of different DataTables
-
Jul 26th, 2007, 03:57 AM
#4
Re: DataTable Comparision
Presumably that column is the primary key. In that case you can do this:
C# Code:
DataRow row2;
foreach (DataRow row1 in table1)
{
row2 = table2.Rows.Find(row1("ID"));
if (row2 != null)
{
// A matching ID was found.
}
}
-
Aug 2nd, 2007, 07:03 AM
#5
Registered User
Re: DataTable Comparision
Try to bind 2 tables ID's in 2 comboboxe and then you can easily compare both the combobox.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|