本文整理汇总了VB.NET中System.Data.DataTableCollection.AddRange方法的典型用法代码示例。如果您正苦于以下问题:VB.NET DataTableCollection.AddRange方法的具体用法?VB.NET DataTableCollection.AddRange怎么用?VB.NET DataTableCollection.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataTableCollection
的用法示例。
在下文中一共展示了DataTableCollection.AddRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: DataTableCollectionAddRange
Public Sub DataTableCollectionAddRange()
' create a DataSet with two tables
Dim dataSet As New DataSet()
' create Customer table
Dim customersTable As New DataTable("Customers")
customersTable.Columns.Add("customerId", _
Type.GetType("System.Int32")).AutoIncrement = True
customersTable.Columns.Add("name", Type.GetType("System.String"))
customersTable.PrimaryKey = New DataColumn() _
{customersTable.Columns("customerId")}
' create Orders table
Dim ordersTable As New DataTable("Orders")
ordersTable.Columns.Add("orderId", _
Type.GetType("System.Int32")).AutoIncrement = True
ordersTable.Columns.Add("customerId", _
Type.GetType("System.Int32"))
ordersTable.Columns.Add("amount", _
Type.GetType("System.Double"))
ordersTable.PrimaryKey = New DataColumn() _
{ordersTable.Columns("orderId")}
dataSet.Tables.AddRange(New DataTable() {customersTable, ordersTable})
' print the tables and their columns
Dim table As DataTable
Dim column As DataColumn
For Each table In dataSet.Tables
Console.WriteLine(table.TableName)
For Each column In table.Columns
Console.Write("{0}" & vbTab, column.ColumnName)
Next
Console.WriteLine()
Next
End Sub