本文整理汇总了VB.NET中System.Data.SqlClient.SqlDataReader.GetValues方法的典型用法代码示例。如果您正苦于以下问题:VB.NET SqlDataReader.GetValues方法的具体用法?VB.NET SqlDataReader.GetValues怎么用?VB.NET SqlDataReader.GetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SqlClient.SqlDataReader
的用法示例。
在下文中一共展示了SqlDataReader.GetValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: TestGetValues
Private Sub TestGetValues(ByVal reader As SqlDataReader)
' Given a SqlDataReader, use the GetValues
' method to retrieve a full row of data.
' Test the GetValues method, passing in an array large
' enough for all the columns.
Dim values(reader.FieldCount - 1) As Object
Dim fieldCount As Integer = reader.GetValues(values)
Console.WriteLine("reader.GetValues retrieved {0} columns.", _
fieldCount)
For i As Integer = 0 To fieldCount - 1
Console.WriteLine(values(i))
Next
Console.WriteLine()
' Now repeat, using an array that may contain a different
' number of columns than the original data. This should work correctly,
' whether the size of the array is larger or smaller than
' the number of columns.
' Attempt to retrieve three columns of data.
ReDim values(2)
fieldCount = reader.GetValues(values)
Console.WriteLine("reader.GetValues retrieved {0} columns.", _
fieldCount)
For i As Integer = 0 To fieldCount - 1
Console.WriteLine(values(i))
Next
End Sub