473,394 Members | 1,674 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,394 software developers and data experts.

Adding to a DataSet

Since I cannot seem to find another group for posting ADO.Net
questions, I'll ask here.

I can create a query that will return a DataSet with one or more tables
in it. Is it possible to execute a query and "add" a table to the
DataSet?

For example, suppose during the process I issue a query that returns a
DataSet with a table that contains Customers in it. Now I want to
issue an additional query that will get Customer Orders but I want this
new DataTable to be added to the existing DataSet. I may further want
to get Order Details and add that table to the DataSet, all with their
appropriate data relations if possible.

How is this done?

Thanks,

Chris

Jul 21 '05 #1
2 1188
>For example, suppose during the process I issue a query that returns a
DataSet with a table that contains Customers in it. Now I want to
issue an additional query that will get Customer Orders but I want this
new DataTable to be added to the existing DataSet.


Yes, of course you can do this! If you have an existing DataSet with a
DataTable "tblCustomers", and you need to add the orders, you would
use ADO.NET's SqlDataAdapter and a SQL query / stored proc as its
"SelectCommand", to retrieve the customer orders, and then you'd call:

mySqlDataAdapter.FillDataSet(dsYourDataSet, "tblOrders")

and you end up with your data set having two tables inside it, one
called "tblCustomers" and another one "tblOrders".

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
Jul 21 '05 #2
Chris,

You can add as much tables in a dataset as you want.

However they need to have a name and with that you have to watch that you
cannot set a relation when there is no table with that name.

As well can you not have missing child parent relations.

This in general.

Cor
Jul 21 '05 #3

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

Similar topics

10
by: Eric Petruzzelli | last post by:
If I fill my dataset and there is no data. The dataset is still created with zero rows (all columns are there). When I add my first row using the script below, it takes over 2 seconds to add??? If...
0
by: lgdev | last post by:
I am using a Dataset with two tables (Customer, Order) and adding a DataRelation object with Nested property set to True. I do not have a schema defined for the dataset. Calling GetXml results in...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
10
by: Trevor | last post by:
Hey, I am trying to do this tutorial on the microsoft site : http://msdn.microsoft.com/library/default.asp? url=/library/en-us/dndotnet/html/usingadonet.asp I can get everything to work up to...
16
by: Geoff Jones | last post by:
Hi Can anybody help me with the following, hopefully simple, question? I have a table which I've connected to a dataset. I wish to add a new column to the beginning of the table and to fill...
6
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire...
6
by: Mark | last post by:
I'm trying to add a table to a dataset but get the error: "A DataTable named 'BordDates0040' already belongs to this DataSet." Code: Dim dtBordDates As DataTable dtBordDates =...
0
by: AboutJAV | last post by:
I created a crystal report with the report.rpt reportdata.xsd I created the a new dataset with the reportdata myreportdata = new reportdata(); That automatically created a new dataset...
1
by: vbDavidC | last post by:
I am adding a new record to a table via a dataset/adapter. I have got the following to work for me but I am wondering if there is a better way to do this. I am having to have something in my...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...

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.