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

How to export a subset of data from a dataset.

Hi,

I was wondering if anyone could help me. I have DataSet that contains
the following data tables Customers, Calls, Quotes, QuoteDetails,
Competitors, Contacts, Notes, and I have setup relationships
betweenthem. Each row in the customer's data table contains an area
number.

What I would like to do is export all records for specific area to an
XML file.

Is there anyway to use the DataSet objects WriteXML method to do this. I
have looked at the documentation and cannot find any example of using
WriteXml to export a part of a dataset.

If it is not possible to do this using WriteXMl, can anyone recommend
another way? I am new at VB.NET, and any help would be really
appreciated.

Thanks in advance
Dave
*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
2 2315
David,
WriteXml writes the entire dataset.

What you need to do is "Create" a dataset that only has a records for a
specific area, then write this dataset.

You can use DataSet.Clone to create a copy of the structure of a DataSet,
without any of the data.
While DataSet.Copy creates a copy of the structure of a DataSet, including
all of the data.

Depending on the amount of data I was keeping verses getting ride of. I
would either Clone the data set, and then use DataTable.ImportRow to import
only my desired data. Or I would use DataSet.Copy & then use DataRow.Delete
to remove the undesired rows. If you have relationships with cascading
deletes, the DataRow.Delete might be the "simpler" solution, albeit more
memory intensive.

The "Trick" with the DataTable.ImportRow is going to be to get all the
parent rows needed... If you have a common id across tables (area?) then you
could just import parent tables for an area first, and then child tables. If
not, I would import the child table, and import the parent row "as needed".

Post if you would like code samples.

Alternatively, you might be able to use DataSet.GetChanges. However this
might be considered a "HACK". Basically you would modify your customers for
an area, then call GetChanges...

Hope this helps
Jay
"David Richards" <da************@tools.co.uk> wrote in message
news:un**************@TK2MSFTNGP10.phx.gbl...
| Hi,
|
| I was wondering if anyone could help me. I have DataSet that contains
| the following data tables Customers, Calls, Quotes, QuoteDetails,
| Competitors, Contacts, Notes, and I have setup relationships
| betweenthem. Each row in the customer's data table contains an area
| number.
|
| What I would like to do is export all records for specific area to an
| XML file.
|
| Is there anyway to use the DataSet objects WriteXML method to do this. I
| have looked at the documentation and cannot find any example of using
| WriteXml to export a part of a dataset.
|
| If it is not possible to do this using WriteXMl, can anyone recommend
| another way? I am new at VB.NET, and any help would be really
| appreciated.
|
| Thanks in advance
| Dave
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #2
Hi,

Thanks you quick response. I will try your ideas and see how it goes.

Thanks again
Dave
*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #3

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

Similar topics

0
by: Shawn Mehaffie | last post by:
I have the following class that I've wirtten to take a Dataset and automatically export it to either XML, ASCII or Tab delimited file. The reason I wrote it they way I did was that I don't want to...
4
by: Gary Wright | last post by:
I have an Access 2K database split into front and back. Quite often the users want to do some data analysis that I have not created a report for so they want to export some subset of the data into...
0
by: Lee Richardson | last post by:
Hi, I have what is probably a fairly simple "best practices" question that I could use help with. I have a Win Forms application that holds it's state in a typed dataset. Part of the dataset...
4
by: Hans [DiaGraphIT] | last post by:
Hi! I want to export a dataset to an excel file. I found following code on the net... ( http://www.codeproject.com/csharp/Export.asp ) Excel.ApplicationClass excel = new ApplicationClass();...
0
by: Shawn Mehaffie | last post by:
I have the following class that I've wirtten to take a Dataset and automatically export it to either XML, ASCII or Tab delimited file. The reason I wrote it they way I did was that I don't want to...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
3
by: H | last post by:
I have a dataset with Customers, Orders, and Items tables. It has datarelations set between Customers-Orders and Orders-Items It has foreignkeyconstraints with update/delete rules set to cascade...
1
by: DennisBetten | last post by:
First of all, I need to give some credit to Mahesh Chand for providing me with an excellent basis to export data to excel. What does this code do: As the title says, this code is capable of...
2
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.