简体   繁体   中英

Vb.Net Dataset table = New DataTable

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?

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"))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM