Vb.Net Dataset table = New DataTable

本秂侑毒 提交于 2019-12-12 04:54:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!