Link to home
Start Free TrialLog in
Avatar of Prysson
Prysson

asked on

How can I add a DataTable to a Dataset

I have an existing DataTable that was populated via a method that passes in a datatable.

How can I then add that Datatable with its existing data to a Dataset...

Or perhaps a better way would be to add a new datatable to Dataset and populatate that datatable with the method called from the other class. Not sure how to do either.

Here are the basics.

there is a method in a class

omni.bll.AppsBLL getsap = new omni.bll.AppsBll();

If I was just goign to fill a Datatable I would  do the following

DataTable dt = new DataTable ();
dt = getsap.vwSap();

But I need to have that DataTable in a Dataset...not sure what I need to do here.
ASKER CERTIFIED SOLUTION
Avatar of TSmooth
TSmooth

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

DataSet ds = new DataSet();
ds.Tables.Add(dt);

DataSet ds = new DataSet();
ds.Tables.Add(myDataTable);

Open in new window

Avatar of AUmidh
AUmidh

omni.bll.AppsBLL getsap = new omni.bll.AppsBll();
DataSet dataSet=new DataSet();    // if you have your own created before this... then use that.
DataTable dt = getsap.vwSap();
dataSet.Tables.Add(dt);