Home All Groups Group Topic Archive Search About

typed dataset and sort order on save

Author
5 Jan 2005 10:25 AM
Donal McWeeney
Hi,

Is it possible to force a typed dataset to write out records with a
particular sort order on the WriteXml() method.

Thanks

    Donal
Author
5 Jan 2005 11:57 AM
Miha Markic [MVP C#]
I doubt it.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

Show quoteHide quote
"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
>
>
Are all your drivers up to date? click for free checkup

Author
5 Jan 2005 11:58 AM
Miha Markic [MVP C#]
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.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

Show quoteHide quote
"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
>
>
Author
5 Jan 2005 12:50 PM
Cor Ligthert
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
Author
5 Jan 2005 1:43 PM
Donal McWeeney
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
>
>
>
>
>
Author
5 Jan 2005 2:13 PM
Miha Markic [MVP C#]
Btw, why do you need an order?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

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...
Author
5 Jan 2005 2:54 PM
Donal McWeeney
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...
Author
5 Jan 2005 4:15 PM
W.G. Ryan eMVP
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...
>
>
Author
5 Jan 2005 2:44 PM
W.G. Ryan eMVP
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
> >
> >
> >
> >
> >
>
>

Bookmark and Share