If you add the datatable returned by the program to a custom dataset, you can directly use the DS. Tables. Add (DT) method.
Datatable already belongs to another dataset "error. At this time, we need to create a new able and import the structure and data of the original datatable.
To the new able, you can use the following method (of course, the method is not the only ONE ):
/// <Summary> <br/> // copy the datatable <br/> /// </Summary> <br/> /// <Param name = "copydt"> data source </param> <br/> /// <Param name = "tablename"> after copying the new able name </param> <br/> /// <returns> </returns> <br/> private datatable copydatatable (datatable copydt, string tablename) <br/>{< br/> datatable dt = new datatable (tablename); <br/> foreach (datacolumn columm in copydt. columns) <br/>{< br/> DT. columns. add (columm. columnname, columm. datatype); <br/>}< br/> foreach (datarow row in copydt. rows) <br/>{< br/> DT. begininit (); <br/> DT. importrow (ROW); <br/> DT. endinit (); <br/>}< br/> return DT; <br/>}