Results 1 to 2 of 2

Thread: Add datatables to dataset???

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Horst
    Posts
    262

    Add datatables to dataset???

    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

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: Add datatables to dataset???

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width