473,320 Members | 1,953 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.

q; merger two dataset

Hello,
Is it possible to merge two datasets which have three tables in each of
them? I am musing .Net 2.0 if this makes anything easier.
Any sample code will be greatly appreciated.
Thanks,

May 22 '06 #1
2 924
The easy way is with the dataset designer. If you want to do it
programmatically, try:

Dim connString As String = My.Settings.ProjectConnection
Dim ds As New DataSet

Using cnn As New SqlClient.SqlConnection(connString)
cnn.Open()
Using cmd As New SqlClient.SqlCommand("mySP", cnn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@myParam", myValue)
Using da As New SqlClient.SqlDataAdapter(cmd)
da.TableMappings.Add("Table", "MyDatasetName1")
da.TableMappings.Add("Table1", "MyDatasetName2")
da.TableMappings.Add("Table2", "MyDatasetName3")
da.Fill(ds)
End Using
End Using
cnn.Close()
End Using

In the stored procedure just write some SQL
SELECT * FROM MyTableName1
SELECT * FROM MyTableName2
SELECT * FROM MyTableName3

It will work equally well with multiple dynamic SQL statements.
May 22 '06 #2
Hello Larry,
Thanks you very much for your reply. This fills the dataset, I need to merge
it with another dataset with the same schema, will that work with three
tables?
"Larry Charlton" wrote:
The easy way is with the dataset designer. If you want to do it
programmatically, try:

Dim connString As String = My.Settings.ProjectConnection
Dim ds As New DataSet

Using cnn As New SqlClient.SqlConnection(connString)
cnn.Open()
Using cmd As New SqlClient.SqlCommand("mySP", cnn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@myParam", myValue)
Using da As New SqlClient.SqlDataAdapter(cmd)
da.TableMappings.Add("Table", "MyDatasetName1")
da.TableMappings.Add("Table1", "MyDatasetName2")
da.TableMappings.Add("Table2", "MyDatasetName3")
da.Fill(ds)
End Using
End Using
cnn.Close()
End Using

In the stored procedure just write some SQL
SELECT * FROM MyTableName1
SELECT * FROM MyTableName2
SELECT * FROM MyTableName3

It will work equally well with multiple dynamic SQL statements.

May 22 '06 #3

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

Similar topics

3
by: Bill C. | last post by:
Hi, I've got a simple console app that just reads an XML file into a DataSet then prints out a description of each table in the DataSet, including column names and row values for each column. ...
1
by: Andy | last post by:
Hello, I have a WebService that sends a client a DataSet as XML (I use a DataSet.GetXml to get the XML). The DataSet is filled by a DataAdapter in the WebService. The client coverts the XML Back...
3
by: Jeronimo Bertran | last post by:
Hi, I have an xml file that encapsulates a dataset definition within a set of tags (<dataset>)... here is an example <?xml version="1.0" encoding="utf-16"?> <dataset> <MyTable>...
5
by: Mike | last post by:
I need to expand the DataSet class by inheriting from it and adding functions that work on the data in the tables. However, since I can't upcast how can I get my base DataSet object assigned an...
2
by: John Holmes | last post by:
I have a web interface where the user types in ID's one at a time. After an ID is typed in, a button is clicked and the button click event has code that does a query and returns a data reader and...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
1
by: JIM.H. | last post by:
I have two datasets and each have three tables in them. Datasets have the same structures and I need to merger these two datasets, (so each table should be merged with its corresponding) how can I...
6
by: Simon | last post by:
on my frmCustomer form i would like a button that open up words and runs a mail merger only with the data on on that form ( as on the mail merger i just want the customer address for when i write a...
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.