PDA

Click to See Complete Forum and Search --> : Add datatables to dataset???


visualsander
Feb 21st, 2005, 10:07 AM
Hi group,

i want to add datatables to a dataset in C#. I checked with msdn and they came up with:
DataSet dataset = new DataSet();
dataset.Tables.Add("aaa");
dataset.Tables.Add("AAA");

So I tried the following:
DataSet ds = new DataSet();
cEmployee emp = new cEmployee();
ds.tables.Add(emp.List);
cCompany comp = new cComp();
ds.tables.add(comp.List);

The List() method fills a dataset with a datatable:
----------------------------------------
here's the partial code:
----------------------------------------

...
DataSet dstemp = new DataSet();
adapter.Fill(dstemp,this.tablename);
return dstemp.tables[This.tablename]
----------------------------------------
I keep getting the error:
DataTable already belongs to a dataset

Does anybody know what I'm doing wrong?

TIA

Regards,
visualsander

nemaroller
Feb 22nd, 2005, 11:32 AM
As the error so esquisitely mentions - the table already belongs to a dataset. So basically, like a god handing out lives, you can't take someone elses and try to call it your own.

Since I forgot to bring my omniscient powers to work today - you'll have to post the rest of your code.