|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
typed dataset and sort order on saveHi,
Is it possible to force a typed dataset to write out records with a particular sort order on the WriteXml() method. Thanks Donal I doubt it.
-- Show quoteHide quoteMiha Markic [MVP C#] - RightHand .NET consulting & development SLODUG - Slovene Developer Users Group www.rthand.com "Donal McWeeney" <macker@newsgroup.nospam> wrote in message news:OnSDCEx8EHA.2060@TK2MSFTNGP10.phx.gbl... > Hi, > > Is it possible to force a typed dataset to write out records with a > particular sort order on the WriteXml() method. > > Thanks > > Donal > > On the second thought, you might create another typeddataset, transfer rows
in desired order (from original dataset) and then invoke WriteXml on this target dataset. -- Show quoteHide quoteMiha Markic [MVP C#] - RightHand .NET consulting & development SLODUG - Slovene Developer Users Group www.rthand.com "Donal McWeeney" <macker@newsgroup.nospam> wrote in message news:OnSDCEx8EHA.2060@TK2MSFTNGP10.phx.gbl... > Hi, > > Is it possible to force a typed dataset to write out records with a > particular sort order on the WriteXml() method. > > Thanks > > Donal > > Donal,
A dataset directly holds no records. However datatables holds rows, do you mean one or more datatables? A simple way for that is this is \\\ DataView dv = new DataView(dt); dv.Sort = "bla"; // sorts column bla DataTable dtnew = dt.Clone(); foreach (DataRowView dvr in dv) dtnew.ImportRow(dvr.Row); dt.Clear(); dt = dtnew.Copy(); /// I hope this helps? Cor Thanks for the replies ... I was hoping to avoid the manual intravention...
Show quoteHide quote "Cor Ligthert" <notmyfirstn***@planet.nl> wrote in message news:OOBfVTy8EHA.2900@TK2MSFTNGP09.phx.gbl... > Donal, > > A dataset directly holds no records. > However datatables holds rows, do you mean one or more datatables? > > A simple way for that is this is > > \\\ > DataView dv = new DataView(dt); > dv.Sort = "bla"; // sorts column bla > DataTable dtnew = dt.Clone(); > foreach (DataRowView dvr in dv) > dtnew.ImportRow(dvr.Row); > dt.Clear(); > dt = dtnew.Copy(); > /// > > I hope this helps? > > Cor > > > > > Btw, why do you need an order?
-- Show quoteHide quoteMiha Markic [MVP C#] - RightHand .NET consulting & development SLODUG - Slovene Developer Users Group www.rthand.com "Donal McWeeney" <macker@newsgroup.nospam> wrote in message news:uaO7gyy8EHA.3708@TK2MSFTNGP14.phx.gbl... > Thanks for the replies ... I was hoping to avoid the manual > intravention... Just playing with a prototype at the moment which will be collecting lots of
data - If I need to manually edit the xml, having it stored in sorted format will make it much easier... XSLT is your friend ;-)
Since a DataSet is comprised of 0 or more tables - sorting is a bit dubious here .... however with XSLT you can sort in any way you want and it's pretty straightforward. Show quoteHide quote "Donal McWeeney" <macker@newsgroup.nospam> wrote in message news:eAu1naz8EHA.2196@TK2MSFTNGP11.phx.gbl... > Just playing with a prototype at the moment which will be collecting lots of > data - If I need to manually edit the xml, having it stored in sorted format > will make it much easier... > > Donal:
You can traverse the XML document very easily using the XML namespace and with XSLT - which you'd only have to write once - you can sort away any way you'd like. Moreoever, like Miha mentions - a sort order on the save probably isn't necessary - you can do the sorting whenever you deserialize the dataset using the code that Cor showed you. Show quoteHide quote "Donal McWeeney" <macker@newsgroup.nospam> wrote in message news:uaO7gyy8EHA.3708@TK2MSFTNGP14.phx.gbl... > Thanks for the replies ... I was hoping to avoid the manual intravention... > > > "Cor Ligthert" <notmyfirstn***@planet.nl> wrote in message > news:OOBfVTy8EHA.2900@TK2MSFTNGP09.phx.gbl... > > Donal, > > > > A dataset directly holds no records. > > However datatables holds rows, do you mean one or more datatables? > > > > A simple way for that is this is > > > > \\\ > > DataView dv = new DataView(dt); > > dv.Sort = "bla"; // sorts column bla > > DataTable dtnew = dt.Clone(); > > foreach (DataRowView dvr in dv) > > dtnew.ImportRow(dvr.Row); > > dt.Clear(); > > dt = dtnew.Copy(); > > /// > > > > I hope this helps? > > > > Cor > > > > > > > > > > > >
Other interesting topics
Constraint violated but no exception thrown
Best way to process millions of records Simple task, can't do in ADO.NET Thread was being aborted Errors Problem with Update Adapter Really need some help on this MDAC and interop.adodb Cascading issues while updating multiple tables with SqlDataAdapter.Update method How can I read a list of files from a folder into a DataTable? Getting off the ground with orace parameters |
|||||||||||||||||||||||