Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / January 2006

Tip: Looking for answers? Try searching our database.

DataSet to Dataview to Dataset to XML!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
matteoalessio@libero.it - 27 Jan 2006 10:12 GMT
Hi everybody,
i've a question for this group: i've  developed a windows service that
every x minutes count records present in a sql table and if those
records are bigger than a fixed threshold start with clean operations.

Workflow is this:

1)  Load records in a DataSet:
DataSet    ds = new DataSet();
cmd = "SELECT * FROM " + TableName;
........
adapter.Fill( ds );

2)Generate a DataView form table inside dataset and order it (i must
order. I tryed to order before load table in DataSet, but table is very
big and often i had timeout)

DataView dv = new DataView(ds.Tables[0]);
string order = GetTimeFieldName ( Table ) + " ASC";
dv.Sort = order;

3) Now i need convert data to XML, but not only one XML file, N XML
file of 10000 records. To do this i generate N DataTable from DataView,
add each DataTable to a New DataSet and call
WriteXML method N time.

The workflow working fine, but i think is not optimal solution (load
dataset, copy to dataview, order dataview, copy again ....... ) ,
someone have a better idea, or some suggestion to gave me?
Cor Ligthert [MVP] - 27 Jan 2006 10:21 GMT
Matt,

If you are using version 2005 than you can use the

Dataview.totable(overloaded function which uses columns)

Otherwise you will have to do it yourself using looping
http://www.vb-tips.com/default.aspx?ID=655b418e-8e9d-4303-8be7-d6ad9bebf57f

I hope this helps,

Cor
W.G. Ryan - MVP - 27 Jan 2006 15:56 GMT
> Hi everybody,
> i've a question for this group: i've  developed a windows service that
[quoted text clipped - 12 lines]
> order. I tryed to order before load table in DataSet, but table is very
> big and often i had timeout)
--I'm not sure I follow you here.  The Timeout is related to the database
right, not the dataset itself?

> DataView dv = new DataView(ds.Tables[0]);
> string order = GetTimeFieldName ( Table ) + " ASC";
[quoted text clipped - 8 lines]
> dataset, copy to dataview, order dataview, copy again ....... ) ,
> someone have a better idea, or some suggestion to gave me?
--  I agree.  One solution would be to pull the data from the DB ordered as
you like, but this adds coupling to your business logic that you probably
don't want. In short, i think XSLT is probably a better way to handle this
problem. This way, you can take any given XML file and have it look however
you need it to. You may even be able to use one file and just apply
different translations to it to get whatever output you need.  One thing
though, I may not understand all of the nuance here. I see the loading  of
the dataset, I see the creation of the View, but where does the copy come n?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.