By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,052 Members | 1,303 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,052 IT Pros & Developers. It's quick & easy.

How do I copy datatable from one dataset to another.

P: n/a
I get dataset from database. I need to take specific datatable out of
it and add it to second dataset to pass back from webservice.

ds.Tables.Add(dsPart.Tables[0]);

I get exception "Datatable already belongs to another dataset"
Which is true :) But why can't I do that?

TIA

Sep 21 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hello Katit,

use Clone() method like ds.Tables.Add(dsPart.Tables[0].Clone());

KI get dataset from database. I need to take specific datatable out of
Kit and add it to second dataset to pass back from webservice.
K>
Kds.Tables.Add(dsPart.Tables[0]);
K>
KI get exception "Datatable already belongs to another dataset" Which
Kis true :) But why can't I do that?
K>
KTIA
K>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Sep 21 '06 #2

P: n/a
Hello Katit,

use Clone() method like ds.Tables.Add(dsPart.Tables[0].Clone());

KI get dataset from database. I need to take specific datatable out of
Kit and add it to second dataset to pass back from webservice.
K>
Kds.Tables.Add(dsPart.Tables[0]);
K>
KI get exception "Datatable already belongs to another dataset" Which
Kis true :) But why can't I do that?
K>
KTIA
K>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Sep 21 '06 #3

P: n/a

Michael Nemtsev wrote:
Hello Katit,

use Clone() method like ds.Tables.Add(dsPart.Tables[0].Clone());
Spasib!

Sep 21 '06 #4

P: n/a

Katit wrote:
Michael Nemtsev wrote:
Hello Katit,

use Clone() method like ds.Tables.Add(dsPart.Tables[0].Clone());

Spasib!
Actually, it should be Copy(). Clone() only gets table with structure,
but no data.

Sep 21 '06 #5

P: n/a
Hello Katit,

yep, sorry, my error :)
it's Copy() definitely

KKatit wrote:
K>
>Michael Nemtsev wrote:
>>Hello Katit,

use Clone() method like ds.Tables.Add(dsPart.Tables[0].Clone());
Spasib!
KActually, it should be Copy(). Clone() only gets table with
Kstructure, but no data.
K>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Sep 21 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.