c# - How to get DataTable From DataSet? -


i have dataset ds contains 10 datatables, each have 1 column only. how make datatable contains columns dataset ds?


public static dataset readxmlusingbufferedstream(string pathofxmlfile)  {     dataset ds = new dataset();     ds.enforceconstraints = false;     if (file.exists(pathofxmlfile))     {        using (filestream filestream = file.openread(pathofxmlfile))        {           bufferedstream buffered = new bufferedstream(filestream);          ds.readxml(buffered);        }     }     ds.enforceconstraints = true;     return ds;  } 

here have marged datatabes available in dataset. if set condition that, add columns of table, should enhanced.

namespace consoleapplication1 {     class program     {         static void main(string[] args)         {             //building dataset having 10 different datatable contains 1 column each             dataset ds = new dataset();                         (int = 0; <= 9; i++)             {                 datatable dt = new datatable();                 dt.columns.add("dt" + + "_column1", typeof(string));                 dt.acceptchanges();                 ds.tables.add(dt);              }             ds.acceptchanges();              //here building datatable consists columns of each , every tables in dataset             datatable dtfinal = new datatable();             foreach (datatable tmp in ds.tables)             {                 dtfinal.merge(tmp);             }         }     } } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -