473,837 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compare Two Identical Datatable By Content

I have 2 datatables. They are identical. I want to compare them by
cell's content. They are all same.

But dt1 == dt2 or
dt1.GetHashCode () == dt2.GetHashCode () doesn 't work.

There are big amount of rows in theese datatables . So i don 't want
to enumerate each rows. This is not efficient and unacceptable for my
current application.

So how can i compare theese datatables by their contents?

Let me describe more in detail :

I have a datatable. dtOld.
In the form load event i am filling this datatable from database and
bound it to a grid.

User may change some data in the grid. Then press save button. At this
point, i can sense which row changed (.GetChanges) and update this row
to database.

So - here is my problem begins :

After this update operation i am requerying the new table from
database and name is as dtNew datatable.

And i already have a datatable which is bound to grid. called dtOld.
I am accepting changes on dtOld.

If no other user made any changes , dtOld and dtNew are same.

In debug mode i can see that they have exact same data.
for instance both of them have 10 rows. and same data in columns.

But when i compared them c# says they are not equal. In theory they
might not equal by reference . Right. But i want to compare by their

How can i manage this in efficient way ?

Dec 18 '06
11 35432
(ignore; wrong topic)
Dec 19 '06 #11
On Tue, 19 Dec 2006 10:33:56 -0000, "Marc Gravell"
<ma**********@g mail.comwrote:
>Why do it this way? Personally, I'd just look for the records that the
user has actively changed, and attempt to save them to the database,
letting the database tell me about concurrency issues (for instance,
by verifying a "timestamp" column at hte point of save). Otherwise, to
ensure that no users change things behind your back you would have to
lock all of the data while checking, which doesn't seem very
efficient. Of course, locking the rows in question is a good idea
(TransactionSc ope or ADO.Net transaction).
Assume that i have 5 rows when i 've load form.

user changed number 4. and i 've updated this info to database. by the
way - user 2 deleted the record number 2 and user three updated the
number four.

I want current user to see fresh data. that 's why i 'm checking.
>Also, by the time you have
fetched all the data from the database, updating the UI is the least
of your issues, so if you have the data, just update it. But if the
data is large, you shouldn't really attempt to do it this way
data is too large.
>There are also (in 2.0) database-oriented change notifications (works
best with SqlServer 2005), but I'm not a big fan of these... not sure
about the scalability... maybe I'm prejudiced though...

my application using both MSSQL2005 and Oracle and other databases
that supports stored procedure.
Dec 19 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Nedu N | last post by:
Hi All, I am facing problem in copying content of table from a untyped dataset into to a table inside the typed dataset. I wanted to copy the data into typed dataset in order to ease the further processing using typed references. DataSet ds = getDataFromDB(); - i am getting the dataset ds from a webservice I have got MyXSD which decsribes the shcema for the table which i am getting from the webservice
by: Eunice | last post by:
Hello. I want to display the content of 'displayTable' object reversely. When from r=0 to r= displayTable.Length-1, the code works well to display. But when from r= displayTable.Length-1 to r=0, the code doesn't work to display. Thanks a lot for any help. **********
by: Nedu N | last post by:
Hi Techies, I am facing problem in copying content of table from a untyped dataset into to a table inside the typed dataset. I wanted to copy the data into typed dataset in order to ease the further processing using typed references. DataSet ds = getDataFromDB(); - i am getting the dataset ds from a webservice I have got MyXSD which decsribes the shcema for the table which i am getting
by: grey | last post by:
does anyone suggest me how to write a windows application for comparing two pdf content. The requirement is very easy... i only need to inform user two pdf are differnet, no need to spot where the difference.
by: ago | last post by:
Hi, Is there any way to compare two identical table structures in access for different values in them. EG: Table 1: Name occupation rob plumber Table 2: Name occupation
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to store a DataTable in any other way outside of our servers. In doing so, we leave ourselves open to large memory requirements. Furthermore, most web pages do not really support multiple changes per transaction. In other words, when the user submits...
by: ndoe | last post by:
how to compare string in file i mean compare that string content digit or alphabet,and 1 question more can we count that line if first line variable = 1,if read second line variable = 2 and so on thanks e.g i have file with name data.txt with file like this 123456
by: madankarmukta | last post by:
Hi, Objectives is to write the DataTable content to the text file in the format Col1 | Col2 | Col3 ------|-------|--------- Val11 | Val21 | Val31 Val12 | Val22 | Val32 Val13 | Val23 | Val33
by: thaopham215 | last post by:
I have a datatable with the ordering of its DataClassIndex column before editting: DataclassIndex 0 1 2 3 4 When I start modifying some other cells in this datatable, the ordering of DataClassIndex column changes to something like this DataclassIndex 3 4 2 1 0 How can I modify a datatable content without altering the original order of the datatable.
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.