PC Review


Reply
Thread Tools Rate Thread

comparing 2 DataRow.ItemArray.Clones

 
 
John B
Guest
Posts: n/a
 
      21st Feb 2005
Hello

On Form Closing I want to find out if the current datarow has been modifed.

I thought I could use the following code to get a copy of the record when
the form is loaded and a second copy in form closing and compare the two.
I am having problems comparing though. If I inspect each object, they appear
similar, but using == returns false. How do I do this?

object record = MyDataTable.Rows[0].ItemArray.Clone();

Thanks

John



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
 
Reply With Quote
 
 
 
 
NuTcAsE
Guest
Posts: n/a
 
      21st Feb 2005
This is a problem with reference equals. For reference types == means
evaluating if they point to the same reference pointer in the heap.
When you execute MyDataTable.Rows[0].ItemArray.Clone(), you are
creating a completely new object with a completely different address
space in memory. Cloning is used to allow modifying one instance
without affecting the other instance.

In your case, id suggest using the following code:

if (MyDataTable.Rows[0].RowState == DateRowState.Modified) {
//DO SOMETHING
}

If u want to use Clone, then you will have to compare the actual values
in the two different ItemArray and see if any value is different.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[.NET1.1] datarow and itemarray =?Utf-8?B?RnJlZGR5Ym95?= Microsoft ADO .NET 1 31st May 2007 06:53 AM
The ItemArray =?Utf-8?B?cm9kY2hhcg==?= Microsoft ASP .NET 3 3rd Apr 2007 04:51 PM
Distinguish 2 situations when a DataRow in Detached state; Or why not make the data row intact after being added then removed from a dataRow collection? Ryan Liu Microsoft C# .NET 0 7th Jun 2006 02:14 AM
Comparing DefaultValue to DataRow column values James Microsoft ADO .NET 5 12th May 2006 12:04 AM
Slow loading DataRow ItemArray Mark Microsoft ADO .NET 2 1st Jul 2005 07:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:44 PM.