467,915 Members | 1,527 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,915 developers. It's quick & easy.

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
  • viewed: 2084
Share:
2 Replies
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Shawn Mehaffie | last post: by
reply views Thread by Lee Richardson | last post: by
4 posts views Thread by Hans [DiaGraphIT] | last post: by
reply views Thread by Shawn Mehaffie | last post: by
3 posts views Thread by H | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.