本文整理匯總了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