国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ADO.NET對象的構造(3)_DataTable(續)

2024-07-10 12:59:38
字體:
來源:轉載
供稿:網友

n overloads public overridable function add() as datatable

n overloads public overridable sub add(byval table as datatable)

n overloads public overridable function add(byval name as string) as datatable

n public sub addrange(byval tables() as datatable)

參數

1. table 要添加的 datatable 對象。

2. name 要賦予已創建的 datatable 的名稱。

3. tables 要添加到集合中的 datatable 對象的數組。



datatablecollection 包含特定 dataset 的所有 datatable 對象。若要訪問 dataset 的 datatablecollection,請使用 tables 屬性。

datatablecollection 使用諸如 add、clear 和 remove 之類的方法管理集合中的項目。

使用 contains 方法確定集合中是否有特定表(由索引或名稱指定)。

若要從一個表瀏覽到另一個表,請使用 datatable 的 childrelations 或 parentrelations 屬性來訪問它的 datarelation 對象的集合。還可使用 relations 屬性瀏覽給定的 dataset 集合中 datatables 的父/子關系。



示例

private sub addtable()

dim dset as dataset= ctype(datagrid1.datasource, dataset)

dim dt as datatable



dt = dset.tables.add("mynewtable")

messagebox.show(dt.tablename)

messagebox.show(dset.tables.count.tostring() & " tables")



dim i as integer

for i = 0 to 2

dset.tables.add()

next i

messagebox.show(dset.tables.count.tostring() & " tables")



dim tables as datatablecollection = ctype(datagrid1.datasource, dataset).tables

tables.add(new datatable)

messagebox.show(dset.tables.count.tostring() & " tables")



dim t as datatable

dim r as datarow

dim c as datacolumn

for each t in dset.tables

console.writeline(t.tablename)

for each r in t.rows

for each c in t.columns

if not (r(c) is nothing) then

console.writeline(r(c))

end if

next

next

next



dim t1 as datatable = new datatable("customers" )

t1.columns.add("customerid", type.gettype("system.int32")).autoincrement = true

t1.columns.add("name", type.gettype("system.string"))

t1.primarykey = new datacolumn() { t1.columns("customerid") }



dim t2 as datatable = new datatable("orders" )

t2.columns.add("orderid", type.gettype("system.int32")).autoincrement = true

t2.columns.add("customerid", type.gettype("system.int32"))

t2.columns.add("amount", type.gettype("system.double"))

t2.primarykey = new datacolumn() { t2.columns("orderid") }



dset.tables.addrange( new datatable() {t1, t2} )



for each t in dset.tables

console.writeline(t.tablename )

for each c in t.columns

console.write("{0}" & vbtab, c.columnname)

next

console.writeline()

next

messagebox.show(dset.tables.count.tostring() & " tables")

end sub

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 甘南县| 饶平县| 宜兰县| 永和县| 邵阳县| 元朗区| 德保县| 祁门县| 扎鲁特旗| 公安县| 霞浦县| 峨山| 浑源县| 张家口市| 金乡县| 新化县| 昌都县| 宜兴市| 新平| 伊川县| 庐江县| 广昌县| 同江市| 水富县| 山阴县| 龙州县| 孟村| 西林县| 南开区| 怀化市| 昌都县| 德昌县| 贡觉县| 射洪县| 荣昌县| 丰城市| 嘉义市| 唐山市| 交城县| 滕州市| 资阳市|