473,786 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataTable.Merge ()

I'm a little confused about DataTable.Merge (). I have two DataTable
objects with the same structure - dtOrig and dtCurrent. The end result
I'm trying to achieve is to get all the rows in dtCurrent that are in
some way different from the corresponding rows in dtOrig so those new/
modified/deleted rows can be processed. My idea was to use
dtOrig.Merge(dt Current), and then call dtOrig.GetChang es(). But what I
found is that when the preserveChanges Merge() parameter is
'false' (or not supplied) the values in dtOrig do get updated, but the
RowState stays 'Unchanged'. When preserveChanges is 'true' then the
RowState for all rows becomes 'Modified' but the values in dtOrig are
NOT actually updated! What am I missing here? Is there a better way to
go about this? Thanks.

May 2 '07 #1
1 15786
Depending on "how" you got to your dtOrig and dtCurrent Datatables, the Merge
method may not give you the behavior you are looking for. This page of the
documentation should help clear things up:

http://msdn2.microsoft.com/en-us/library/fk68ew7b.aspx

sorry if dupe, MS' web thang not cooperating today.

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"mj****@yahoo.c om" wrote:
I'm a little confused about DataTable.Merge (). I have two DataTable
objects with the same structure - dtOrig and dtCurrent. The end result
I'm trying to achieve is to get all the rows in dtCurrent that are in
some way different from the corresponding rows in dtOrig so those new/
modified/deleted rows can be processed. My idea was to use
dtOrig.Merge(dt Current), and then call dtOrig.GetChang es(). But what I
found is that when the preserveChanges Merge() parameter is
'false' (or not supplied) the values in dtOrig do get updated, but the
RowState stays 'Unchanged'. When preserveChanges is 'true' then the
RowState for all rows becomes 'Modified' but the values in dtOrig are
NOT actually updated! What am I missing here? Is there a better way to
go about this? Thanks.

May 2 '07 #2

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

Similar topics

2
5602
by: VMI | last post by:
How can I dump a datatable into an Access table (which contais exactly the same structure)? Somebody suggested doing this with a dataAdapter. I don't want to run an Insert query for each record (I assume that if the datatable and the Access table have the same structure, I can just dump it from one place to the other). I'd be dumping data to the same Access table several times (append). Thanks.
11
19736
by: Bruce D | last post by:
I have a DataTable that I need to merge the 'lastname' and 'firstname' fields to be displayed in a datagrid. I know I can use the SQL statement to merge the fields into one, but I want to know if it's possible to do through the DataTable, DataView or DataGrid that I have already created to display the data. This should be easy...right? -bruce duncan
1
1751
by: astro | last post by:
I am trapping the rowchanged event on a table. I have the following code: If e.Action = DataRowAction.Add Then ds.Merge(CType(sender, DataTable).Select("", "", System.Data.DataViewRowState.Added)) The funny thing is - the merge operation captures No rows.
1
1268
by: Marcel Hug | last post by:
Hello NG ! I have a tricky question about dataSet and dataTable. In my app I have 2 databases. In the first (called A1) database are the whole datas but I'm interesting in one table tbl1 (with 20 attributes). To communicate with the DB A1 I have a lib, which gives me a dataset of this table tbl1 (with all attributes). This dataset i would like to give the lib for my second DB A2. In this DB A2 is a table tbl2 which has just some of the...
3
13275
by: Wasco | last post by:
Hi! Does Anibody knows how can i perform two query sql on db from c#? Sample: if i do string QDAccount = "select * TABLE1;select * from TABLE2"; then i execute then and i get a DataSet with 2 tables: ds is a dataset
2
7360
by: RSH | last post by:
Hi, Iam struggling with an application where I am trying to transfer a datarow from one sql server to another instance of sql server. The schmeas may be slightly different and I am getting an exception when they are different. Is there anyway i can modify the code below so that if the schemas are different I can drop the offending column in the appropriate datatable? Thanks, Ron
9
15602
by: Pascal Berger | last post by:
What's the fastest way to accomplish the following tasks: - Copy all data from one DataTable to another. Currently I work with CreateDataReader() / Load(). Is there any faster approach? - Add a lot of rows (>10'000) to a DataTable (one by one). Currently I use NewRow() / AddRow(). It's painfully slow. I know I can disable indexing during the import. Any other possible optimizations? Thanks in advance Pascal
2
2500
by: =?Utf-8?B?Sm9iIExvdA==?= | last post by:
How can I reconcile changes between two data table and create a subset of those changes. I have two data tables with same schema which gets populated from two different xml files. I want to get hold of missing & changed rows in first table from second table. Tables have ID as primary key. Thanks
1
2860
by: mj2736 | last post by:
I'm a little confused about DataTable.Merge(). I have two DataTable objects with the same structure - dtOrig and dtCurrent. The end result I'm trying to achieve is to get all the rows in dtCurrent that are in some way different from the corresponding rows in dtOrig so those new/ modified/deleted rows can be processed. My idea was to use dtOrig.Merge(dtCurrent), and then call dtOrig.GetChanges(). But what I found is that when the...
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
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...
0
10169
jinu1996
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...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
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
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
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.