Connecting Tech Pros Worldwide Help | Site Map

How to export a subset of data from a dataset.

David Richards
Guest
 
Posts: n/a
#1: Nov 21 '05
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 ***
Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
#2: Nov 21 '05

re: How to export a subset of data from a dataset.


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" <david.richards@tools.co.uk> wrote in message
news:unvu4$OnFHA.3568@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 ***


David Richards
Guest
 
Posts: n/a
#3: Nov 21 '05

re: How to export a subset of data from a dataset.


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 ***
Closed Thread


Similar Visual Basic .NET bytes