Vb.Net Dataset table = New DataTable [英] Vb.Net Dataset table = New DataTable
本文介绍了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.
但不幸的是,这不起作用,因为错误:属性'Item'是只读
But Unfortunately this does not work because error: property 'Item' is read only
有没有完成这个?
推荐答案
DataSet的Tables集合可以是使用添加,删除方法修改
The Tables collection of a DataSet could be modified using the Add, Remove methods
dsDataSet.Tables.Add(new DataTable("promotion"))
当然,上面的一行要求该集合不包含名为promotion的表。如果您的数据集中已经有一个名为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"))
这篇关于Vb.Net Dataset table = New DataTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文