PC Review


Reply
Thread Tools Rate Thread

dataset.merge not working correctly

 
 
=?Utf-8?B?Q2hyaXM=?=
Guest
Posts: n/a
 
      29th Dec 2005
Hi,
I am trying to merge two datasets into one, each dataset has one table when
I merge the two datasets I get a dataset with two tables? I need the merged
dataset to only contain one table with the merged data. Does anyone know how
to avoid this?
 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      29th Dec 2005
Why don't you try using DataTable.Merge?

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Chris" <(E-Mail Removed)> wrote in message
news:66AB3CBC-BAE1-4FD6-A87D-(E-Mail Removed)...
> Hi,
> I am trying to merge two datasets into one, each dataset has one table
> when
> I merge the two datasets I get a dataset with two tables? I need the
> merged
> dataset to only contain one table with the merged data. Does anyone know
> how
> to avoid this?



 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      29th Dec 2005
Chris,

The problem with this are almost forever the same.
The table names are different
The tables don't have primary keys

http://www.vb-tips.com/default.aspx?...f-de3a5d92b14a

I hope this helps,

Cor


 
Reply With Quote
 
=?Utf-8?B?Q2hyaXM=?=
Guest
Posts: n/a
 
      29th Dec 2005
Cor,

Thanks, I figured that. I tried it and it works, sort of. It seems that I
can only get this to work by setting the name of the second table to the name
of the first table. Creating / setting primary keys on each table. But then
the only way to get the merge to work is to loop through each record in the
second table, adding each row to an array and merging the array for each row
individually. I don't care that I have to do it this way, see ex.1 below,
I'm just happy that it works. Thank you for your help

ex 1


Me.SqlDataAdapter1.Fill(DsTest11)
Me.SqlDataAdapter2.Fill(DsTest21)
Me.DsTest21.Tables(0).TableName = "Test1"

Dim pk1(1) As DataColumn
pk1(0) = Me.DsTest11.Tables(0).Columns("TestNumber1")
Me.DsTest11.Tables(0).PrimaryKey = pk1

Dim pk2(1) As DataColumn
pk2(0) = Me.DsTest21.Tables(0).Columns("TestNumber1")
Me.DsTest21.Tables(0).PrimaryKey = pk2

Dim dr As DataRow
For Each dr In Me.DsTest21.Tables(0).Rows
Dim dra(0) As DataRow
dra(0) = dr
Me.DsTest11.Merge(dra)
Next
Me.DataGrid3.DataSource = Me.DsTest11.Test1

For whatever reason just calling Me.DsTest11.Merge(Me.DsTest21) will not
give me the combined results.



"Cor Ligthert [MVP]" wrote:

> Chris,
>
> The problem with this are almost forever the same.
> The table names are different
> The tables don't have primary keys
>
> http://www.vb-tips.com/default.aspx?...f-de3a5d92b14a
>
> I hope this helps,
>
> Cor
>
>
>

 
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
after dataset.merge(..) datacolumn.expression is not working? Giedrius Microsoft ADO .NET 1 12th Aug 2005 03:41 PM
DataAdapter not working after Merge with other Dataset kirck Microsoft ADO .NET 7 24th Mar 2005 06:39 PM
DataSet.Merge where data being merge has less rows than the oringal source Dan Hibbert Microsoft ADO .NET 2 20th Jan 2005 06:35 PM
how to use merge with a typed dataset and untyped dataset vipin kumar Microsoft ADO .NET 0 1st Oct 2003 02:21 PM
Re: DataSet.Merge: DataSet.HasChanges returns true Markus Wildgruber Microsoft ADO .NET 6 4th Sep 2003 01:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:00 AM.