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