本文整理汇总了VB.NET中System.Data.DataTableReader.HasRows属性的典型用法代码示例。如果您正苦于以下问题:VB.NET DataTableReader.HasRows属性的具体用法?VB.NET DataTableReader.HasRows怎么用?VB.NET DataTableReader.HasRows使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。
在下文中一共展示了DataTableReader.HasRows属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: TestHasRows
Private Sub TestHasRows()
'Retrieve one row from the Store table:
Dim customerTable As DataTable = GetCustomers()
Dim productsTable As DataTable = GetProducts()
Using reader As New DataTableReader( _
New DataTable() {customerTable, productsTable})
Do
If reader.HasRows Then
PrintData(reader)
End If
Loop While reader.NextResult()
End Using
Console.WriteLine("Press Enter to finish.")
Console.ReadLine()
End Sub
Private Sub PrintData( _
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("{0} ", reader(i))
Next
Console.WriteLine()
Loop
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"})
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}
Return table
End Function