473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

DataSet Merge?

Hi,

I am confused as what the DataSet Merge() function does.

Currently I have two datatable which was selected from different table in
mssql.

Now with both different datatable. there are unique keys which determine the
the relationship.

Ex

Table 1 Name - Employer
Fields - id, name, age
Values -
1, Joe, 80
2, Bob, 23
3, Fred, 40

Table 2 Name - Car
Fields - id, car, price
Values -
1, Ferrari, 1.0
2, Volvo, 0.8

Now, by using id as the relationship, doing a merge I would like to get

New Table
Values - id, name, age, id, car, price
1, Joe, 80, Ferrari, 1.0
2, Bob, 23, Volvo, 0.8
3, Fred, 40 , null, null

Is this possible? How do I go about doing this? Please note I cannot use a
join sql statement, as the values selected out has already been processed by
different complex business logic.

I have followed the example on this site
http://weblogs.sqlteam.com/davidm/ar...01/20/748.aspx, which gives
me the result that i want(after tweaking it). However this requires looping
and extra coding to merge them up by parsing the rows of both table. Is
there a function in DataSet to do something like the above example?

Thanks

Joey

Nov 19 '05 #1
1 1529
There is nothing inherent in the DataSet that would let you do that. You
have to create a DataTable outside of the data set, and add it to the
dataset when you are done filling the values. Something like:

DataTable myTable = new DataTable();
DataTable.TableName = "MyTable";

// Create columns, and add data here
....
....

// Add the table to the DataSet
myDataSet.Add(myTable);

Note: If you did not have the complex business logic requirement, you could
just create a DataView that joins the existing tables in the set.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Joey Lee" <jo*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,

I am confused as what the DataSet Merge() function does.

Currently I have two datatable which was selected from different table in
mssql.

Now with both different datatable. there are unique keys which determine the the relationship.

Ex

Table 1 Name - Employer
Fields - id, name, age
Values -
1, Joe, 80
2, Bob, 23
3, Fred, 40

Table 2 Name - Car
Fields - id, car, price
Values -
1, Ferrari, 1.0
2, Volvo, 0.8

Now, by using id as the relationship, doing a merge I would like to get

New Table
Values - id, name, age, id, car, price
1, Joe, 80, Ferrari, 1.0
2, Bob, 23, Volvo, 0.8
3, Fred, 40 , null, null

Is this possible? How do I go about doing this? Please note I cannot use a
join sql statement, as the values selected out has already been processed by different complex business logic.

I have followed the example on this site
http://weblogs.sqlteam.com/davidm/ar...01/20/748.aspx, which gives
me the result that i want(after tweaking it). However this requires looping and extra coding to merge them up by parsing the rows of both table. Is
there a function in DataSet to do something like the above example?

Thanks

Joey


Nov 19 '05 #2

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

Similar topics

8
by: Bruce Stockwell | last post by:
the setup: Webservice/WinClient application/SQL server. VS.Net (visual basic) winform wizard creates a simple form with load cancel cancelall and datagrid bound to a simple Dataset with one...
3
by: Li Weng | last post by:
Hi, I have an original dataset. It is copied to 2 different forms. Each form adds a new row to the same table in that dataset. When I merge these 2 dataset back to original one, the 2 new rows...
2
by: Mike Stephens | last post by:
A contact management application we previously developed for a customer now has a requirement to perform mail merging. Normally request like this would be very simple to solve, we were just point...
2
by: muntyanu | last post by:
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(...
4
by: Al | last post by:
I have this scenario: 1. XML file with schema and data is created from SQL Server tables. XML file contains 6 tables, some of them have rows, some of them are empty. 2. XML file is given to the...
1
by: matt | last post by:
hello, i have a web app that allows users to query our oracle db and produce a dataset of report data. they then have the option to serialize this data and store it in the database. later, then...
5
by: Mark Chambers | last post by:
Hi there, Can anyone explain the following (very) simple scenario. 1) I make an exact copy of my "DataSet" and delete one record from a given table (in the copy) 2) I invoke...
5
by: Franck | last post by:
how come unchanged always true even if data changed This code come from my saving button: ============================================ DataSet ds1 = new DataSet(); DataSet ds2 = new...
2
by: Neil Chambers | last post by:
I am trying to get my head around dataset merging but despite a little research I could still use a pointer (or ten). Basically I want to perform an outer join operation on a dataset (created from...
1
by: joproulx | last post by:
Hello all, Here is my problem: I am trying to merge 2 datasets but I don't want to overwrite rows that are already modified in my working dataset. Example: I have one Dataset with only one...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.