473,557 Members | 2,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can not add rows into dataset using Merge()

Hi all,

I have problem when merging existing DataTable into new dataset.
DataSet ds = new DataSet();
while ( done )
{
// fill myCustomDataSet .MyTable with data
ds.Merge( myCustomDataSet .MyTable, bPreserveChange s,
MissingSchemaAc tion.Add );
ds.AcceptChange s(); // tried with and without this line
}
In the loop I am filling my datatable and then I need to add all
content to new dataset.
I tried all combinations for bPreserveChange s, MissingSchemaAc tion but
can not accumulate rows in new dataset. If bPreserveChange s = true I
have only rows which were added during first call to Merger. If
bPreserveChange s = false I have rows from the last call to Merge.
Tried also to have myCustomDataSet .MyTable with or without primary
key. No difference.

I would really appreciate any suggestions

Thank you , Roman

Dec 13 '05 #1
2 2100
Roman,
It "looks like" from the code you posted that you may be attempting to use
the Merge method to add a table to a target DataSet. What merge is really
designed to do is where each DataSet initially contains a single DataTable
with the same name. After you call the Merge method on the main DataSet and
supply the second DataSet, the main DataSet will contain all its original
columns plus those from the second DataSet. The main DataSet will also
contain the rows from the second DataSet.

Hope that helps,
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"mu******@hotma il.com" wrote:
Hi all,

I have problem when merging existing DataTable into new dataset.
DataSet ds = new DataSet();
while ( done )
{
// fill myCustomDataSet .MyTable with data
ds.Merge( myCustomDataSet .MyTable, bPreserveChange s,
MissingSchemaAc tion.Add );
ds.AcceptChange s(); // tried with and without this line
}
In the loop I am filling my datatable and then I need to add all
content to new dataset.
I tried all combinations for bPreserveChange s, MissingSchemaAc tion but
can not accumulate rows in new dataset. If bPreserveChange s = true I
have only rows which were added during first call to Merger. If
bPreserveChange s = false I have rows from the last call to Merge.
Tried also to have myCustomDataSet .MyTable with or without primary
key. No difference.

I would really appreciate any suggestions

Thank you , Roman

Dec 13 '05 #2
Peter, thank you for response
I think namespaces involved in this issue. My table in custom dataset
depends on complex types which are in separate xsd files. When I
created simple example with no dependencies to namespaces I can
accumulate rows in new dataset. But this is not a case in my real
application. This is my test app that works
private void button1_Click(o bject sender, System.EventArg s e)
{
Source source = new Source();
Source.Table1Ro w row = source.Table1.N ewTable1Row();
row.ID = "1";
row.f1 = "string for f1 (first time)";
row.f2 = "string for f2 (first time)";
source.Table1.A ddTable1Row(row );
// Merge to target
m_TargetDataSet .Merge(source.T able1);
m_TargetDataSet .WriteXml(@"c:\ First_Merge.xml ");

}

private void button2_Click(o bject sender, System.EventArg s e)
{
Source source = new Source();
Source.Table1Ro w row = source.Table1.N ewTable1Row();
row.ID = "1";
row.f1 = "string for f1 (second time)";
row.f2 = "string for f2 (second time)";
source.Table1.A ddTable1Row(row );
// Merge to target
m_TargetDataSet .Merge(source.T able1);

m_TargetDataSet .WriteXml(@"c:\ Second_Merge.xm l");
}
I will try to set namespaces properly

Roman

Dec 13 '05 #3

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

Similar topics

3
2771
by: Tome73 | last post by:
How can I easily add the rows of DataTable1 to the rows of DataTable2. Both queries are from the same table. I can always use the column names with myRow, but I was wishing for a shortcut. When I try this it doesn’t work. for (int i = 0; i < dataTable1.Rows.Count; i++) { myRow = dataTable2.NewRow(); myRow = dataTable1.Rows;...
7
12050
by: Egor Shipovalov | last post by:
I'm implementing paging through search results using cursors. Is there a better way to know total number of rows under a cursor than running a separate COUNT(*) query? I think PostgreSQL is bound to know this number after the first FETCH, isn't it? On a side note, why queries using LIMIT are SO terribly slow, compared to cursors and...
1
1713
by: Mike Hnatt | last post by:
I'm baffled. My data store (database) is not updating with a refreshed dataset. Here's what is going on: 1) Create a dataset from a table in a database. 2) Create a copy of this dataset and maniuplate (update some records) 3) Now, merge this copied dataset back into the original dataset (using the Merge method) 4) Now display this...
7
2206
by: Nitromuse | last post by:
Hello, I'm trying to merge two datsets which both have a common keyed column, and getting nowhere. Do I want to use the keyed column or not? I'm using the following and have tried all the constraints every which way. Dataset1.Merge(Dataset2) Can anyone shed some light on merging, I thought it was going to be simple, but there I go...
5
1669
by: Geoff Jones | last post by:
Hi Suppose we have an array of DataRows e.g. Dim drMyRows() As DataRow = myTable.Rows(0).GetChildRows("PricesCompany") generated via a relationship. The question I have is this. Isn't this in essence a table i.e. a collection of rows? The reason I ask is that I wanted to extract from the array of rows
2
1630
by: dbuchanan | last post by:
Where is the logic error that causes the attached code to adds two rows instead on one to the datagrid? The code correctly update the datasource with one row, but the datagrid gets two new rows. What can I do to correct this? Circumstances: There are textboxes on the form where the users will enter data. The
4
8597
by: RG | last post by:
Using VB.NET, How do I insert rows from a SQL Server table into an Access table with the same structure (and also the reverse, from Access to SQL)? I’m new to this, so here’s what I’ve tried so far (unsuccessfully): 1. Fill Dataset ‘S’ from a SQL Data Adapter (many rows). I see it in a DataGrid. 2. Fill Dataset ‘A’ from...
0
846
by: Steven Bolard | last post by:
Hi Im using .net 2.0 and i am merging a table from one strongly typed dataset into another. If i then do a select on the rows within the table I merged and subsequently try to access the columns of any of those rows using the strongly typed name, i get an exception saying column "Column1' does not belong to table 'Table1'. i.e Dim ds As...
11
2535
by: UDBDBA | last post by:
Hi: This is a merge questions which has been posted and answered... in my case need more clairification when target table (tableB) matched multiple rows to be updated based on the ON condition for a single row from source table (tableA). There is a one to many relationship from source to target table (because of the ON condition). We also...
0
7835
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. ...
1
7593
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7914
tracyyun
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...
0
6183
agi2029
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5172
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...
0
3602
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...
1
2045
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
1
1164
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
869
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...

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.