Home All Groups Group Topic Archive Search About

Moving data from one dataset to another

Author
15 Feb 2006 4:01 PM
SH
What is the easiest way to move data from one dataset to another?

I have a web service that returns a dataset from a datasource. I then
want to move all the data in one datatable in that dataset to another
datatable in another dataset. (For instance, a table of Employees is
returned in the web service dataset. I then want to move all those
Employees into an Employees datatable in my local dataset.)

The first way that comes to mind is to use a loop - read and move each
record individually. I'm wondering if there is a single command that
will do it without a loop. (I'm programming in VB.NET, so the VB version
of the command would be appreciated if possible, although I can
cross-reference the C# version myself.)

Thanks for any assistance.

Author
15 Feb 2006 4:49 PM
W.G. Ryan - MVP
Createa a new DataSet and call the merge method, passing in the first, if I
udnerstand you correctly, this should work. If you copy item by item, you're
rowstate's won't necessarily be in sync and this can be a big problem.  In
the 2.0 Framework you can manipulate Rowsate
http://msmvps.com/blogs/williamryan/archive/2006/01/14/81063.aspx
but in the 1.x, you're limited.
Show quote
"SH" <sham***@prupipe.com> wrote in message
news:NfIIf.1756$UN.1274@newsread2.news.pas.earthlink.net...
> What is the easiest way to move data from one dataset to another?
>
> I have a web service that returns a dataset from a datasource. I then want
> to move all the data in one datatable in that dataset to another datatable
> in another dataset. (For instance, a table of Employees is returned in the
> web service dataset. I then want to move all those Employees into an
> Employees datatable in my local dataset.)
>
> The first way that comes to mind is to use a loop - read and move each
> record individually. I'm wondering if there is a single command that will
> do it without a loop. (I'm programming in VB.NET, so the VB version of the
> command would be appreciated if possible, although I can cross-reference
> the C# version myself.)
>
> Thanks for any assistance.

AddThis Social Bookmark Button