Re: on merging datasets and datatables
From: Kai Brinkmann [MSFT] (kaibrink_at_online.microsoft.com)
Date: 12/03/04
- Next message: Greg Smith: "An enum of controls?"
- Previous message: Simon: "Re: Returning an error message when something goes wrong"
- In reply to: Phil Townsend: "on merging datasets and datatables"
- Next in thread: David Browne: "Re: on merging datasets and datatables"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 3 Dec 2004 10:39:22 -0800
Your code doesn't work because you are simply creating another reference to
an existing DataTable object; you are not actually creating a new data
table. To do that, you need to use the Clone() method:
DataSet ds = new DataSet();
DataTable dtroles = ((DataSet)Cache["fullrolelist"]).Tables[0].Clone();
DataTable dtsub = ((DataSet)Cache["subcommittees"]).Tables[0].Clone();
ds.Tables.Add(dtroles);
ds.Tables.Add(dtsub);
Hope that helps.
-- Kai Brinkmann [MSFT] Please do not send e-mail directly to this alias. This alias is for newsgroup purposes only. This posting is provided "AS IS" with no warranties, and confers no rights. "Phil Townsend" <phil25840@yahoo.com> wrote in message news:uv$svVW2EHA.1076@TK2MSFTNGP09.phx.gbl... >I am working in a web app that contains two datasets that are cached. I > would like to pull the first table from each dataset [0] and put each > into a single dataset, so as to have a single dataset with the > following: > > DataSet ds=new DataSet(); > DataTable dtroles=((DataSet)Cache["fullrolelist"].Tables[0]); > DataTable dtsub=((DataSet)Cache["subcommittees"].Tables[0]); > ds.Tables.Add(dtroles); > ds.Tables.Add(dtsub); > > When I try this I get an error saying that these data tables already > belong to another dataset. Is there a way to extract a table from a > dataset and place it into another dataset? Am I approacing this the > right way? Thanks! > > > > *** Sent via Developersdex http://www.developersdex.com *** > Don't just participate in USENET...get rewarded for it!
- Next message: Greg Smith: "An enum of controls?"
- Previous message: Simon: "Re: Returning an error message when something goes wrong"
- In reply to: Phil Townsend: "on merging datasets and datatables"
- Next in thread: David Browne: "Re: on merging datasets and datatables"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
Loading