问题
I came across one programming issue that I have tried to solve it as follows:
dsDataSet.Tables("promotion") = New DataTable.
But Unfortunately this does not work because error: property 'Item' is read only
Is there away to accomplish this?
回答1:
The Tables collection of a DataSet could be modified using the Add, Remove methods
dsDataSet.Tables.Add(new DataTable("promotion"))
of course, the line above requires that the collection doesnt already contain a table named "promotion". If you have already a table named "promotion" in your dataset then you need to remove it before adding the new one
dsDataSet.Tables.Remove("promotion")
dsDataSet.Tables.Add(new DataTable("promotion"))
来源:https://stackoverflow.com/questions/23967676/vb-net-dataset-table-new-datatable