国产探花免费观看_亚洲丰满少妇自慰呻吟_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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东莞市| 稻城县| 和田县| 建水县| 雅江县| 嘉善县| 林芝县| 左贡县| 孝感市| 婺源县| 佳木斯市| 威信县| 时尚| 河曲县| 铁岭市| 阳原县| 广南县| 都昌县| 加查县| 闸北区| 株洲县| 古浪县| 改则县| 秀山| 宁城县| 昌邑市| 湖南省| 密山市| 尤溪县| 肥城市| 彭山县| 弋阳县| 承德市| 盈江县| 白玉县| 灌南县| 乐昌市| 惠水县| 孝感市| 方城县| 胶州市|