how to store multiple DataTables into single DataSet in c#?

后端 未结 1 1009
一生所求
一生所求 2020-12-06 03:19

I have the code below which has multiple DataTables with results and I need to pass a single DataSet with all DataTable values.

MySqlCommand cmd = new MySqlC         


        
相关标签:
1条回答
  • 2020-12-06 03:34
    DataSet ds = new DataSet();
    ds.Tables.Add(dt);
    ds.Tables.Add(dt1);
    ...
    

    If you want your tables named in the DataSet you can create your tables from the DataSet

    DataSet ds = new DataSet();
    DataTable t1 = ds.Tables.Add("t1");  // Create
    DataTable t1Again = ds.Tables["t1"]; // fetch by name
    

    You can also set the TableName property of the tables if you use the first approach.

    0 讨论(0)
提交回复
热议问题