本文整理汇总了VB.NET中System.Data.DataTableReader.NextResult方法的典型用法代码示例。如果您正苦于以下问题:VB.NET DataTableReader.NextResult方法的具体用法?VB.NET DataTableReader.NextResult怎么用?VB.NET DataTableReader.NextResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了DataTableReader.NextResult方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: TestConstructor
Private Sub TestConstructor()
' Create two data adapters, one for each of the two
' DataTables to be filled.
Dim customerDataTable As DataTable = GetCustomers()
Dim productDataTable As DataTable = GetProducts()
' Create the new DataTableReader.
Using reader As New DataTableReader( _
New DataTable() {customerDataTable, productDataTable})
' Print the contents of each of the result sets.
Do
PrintColumns(reader)
Loop While reader.NextResult()
End Using
Console.WriteLine("Press Enter to finish.")
Console.ReadLine()
End Sub
Private Function GetCustomers() As DataTable
' Create sample Customers table, in order
' to demonstrate the behavior of the DataTableReader.
Dim table As New DataTable
' Create two columns, ID and Name.
Dim idColumn As DataColumn = table.Columns.Add("ID", GetType(Integer))
table.Columns.Add("Name", GetType(String))
' Set the ID column as the primary key column.
table.PrimaryKey = New DataColumn() {idColumn}
table.Rows.Add(New Object() {1, "Mary"})
table.Rows.Add(New Object() {2, "Andy"})
table.Rows.Add(New Object() {3, "Peter"})
table.Rows.Add(New Object() {4, "Russ"})
Return table
End Function
Private Function GetProducts() As DataTable
' Create sample Products table, in order
' to demonstrate the behavior of the DataTableReader.
Dim table As New DataTable
' Create two columns, ID and Name.
Dim idColumn As DataColumn = table.Columns.Add("ID", GetType(Integer))
table.Columns.Add("Name", GetType(String))
' Set the ID column as the primary key column.
table.PrimaryKey = New DataColumn() {idColumn}
table.Rows.Add(New Object() {1, "Wireless Network Card"})
table.Rows.Add(New Object() {2, "Hard Drive"})
table.Rows.Add(New Object() {3, "Monitor"})
table.Rows.Add(New Object() {4, "CPU"})
Return table
End Function
Private Sub PrintColumns( _
ByVal reader As DataTableReader)
' Loop through all the rows in the DataTableReader.
Do While reader.Read()
For i As Integer = 0 To reader.FieldCount - 1
Console.Write(reader(i).ToString() & " ")
Next
Console.WriteLine()
Loop
End Sub