本文整理汇总了VB.NET中System.Data.DataTableCollection.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:VB.NET DataTableCollection.RemoveAt方法的具体用法?VB.NET DataTableCollection.RemoveAt怎么用?VB.NET DataTableCollection.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.DataTableCollection
的用法示例。
在下文中一共展示了DataTableCollection.RemoveAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: DataTableCollectionRemoveAt
Public Sub DataTableCollectionRemoveAt()
' Create a DataSet with two tables and then
' remove the tables from the collection using RemoveAt.
Dim dataSet As New DataSet()
' Create Customer table.
Dim customerTable As New DataTable("Customers")
customerTable.Columns.Add("customerId", _
GetType(Integer)).AutoIncrement = True
customerTable.Columns.Add("name", GetType(String))
customerTable.PrimaryKey = New DataColumn() _
{customerTable.Columns("customerId")}
' Create Orders table.
Dim ordersTable As New DataTable("Orders")
ordersTable.Columns.Add("orderId", _
GetType(Integer)).AutoIncrement = True
ordersTable.Columns.Add("customerId", GetType(Integer))
ordersTable.Columns.Add("amount", GetType(Double))
ordersTable.PrimaryKey = New DataColumn() _
{ordersTable.Columns("orderId")}
dataSet.Tables.AddRange(New DataTable() _
{customerTable, ordersTable})
' Remove all tables.
' First check to see if the table can be removed,
' then remove it.
'
' You cannot use a foreach when removing items
' from a collection.
Do While (dataSet.Tables.Count > 0)
Dim table As DataTable = dataSet.Tables(0)
If (dataSet.Tables.CanRemove(table)) Then
dataSet.Tables.RemoveAt(0)
End If
Console.WriteLine("dataSet has {0} tables", _
dataSet.Tables.Count)
Loop
End Sub