473,513 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I copy datatable from one dataset to another.

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
5 38742
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
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

Michael Nemtsev wrote:
Hello Katit,

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

Sep 21 '06 #4

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9668
by: Top Gun | last post by:
Is there an easy way to do this?
0
3128
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
0
1229
by: Bennett Haselton | last post by:
If I have just filled a DataTable in a typed DataSet with a single row, is there a way I can make a copy of that row, so that I can clear the DataTable in that DataSet and use it for another query,...
1
2004
by: cindy | last post by:
Get data into datatable, add to dataset dsSearch " Get data into datatable, add to dataset dsSearch Using In-Memory SQL Engine join the tables and select the filenames from the join, add to...
3
2505
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and...
10
6503
by: dauphian | last post by:
Hello, I am new to .net and am trying to build a report application that queries 4 different tables based on a id, and I need to return them in the same table for easy viewing. Basically, I...
4
2462
by: JIM.H. | last post by:
Hello, I am trying to write the data I got from a web service to my table in SQL Server I need to append the dataset wsDS to the dataset ds and do update. PVS.myWS.Loader load = new...
0
1208
by: Mdotnetdeveloper | last post by:
hi, i am trying to achieve this: i have 2 different databses. i need to get data from one databse (for eg. in a datset), copy it into another dateset (pointing to the second database), make...
4
2281
by: Soulless | last post by:
Hi, is there any way to copy a dataset to a datagrid? I have a dataset and want to copy to a datagridview, but I get no results.... thx!
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7545
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7539
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5692
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5095
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.