DataTableReader.GetValues メソッド
アセンブリ: System.Data (system.data.dll 内)

Dim instance As DataTableReader Dim values As Object() Dim returnValue As Integer returnValue = instance.GetValues(values)
戻り値
配列にコピーされる列の値の数。


アプリケーションでは、ほとんどの場合、このメソッドを利用してすべての列をまとめて取得する方が、各列を個別に取得するよりも効率的です。DataTableReader 内にある行から列の値をすべて取得する場合、GetValues メソッドを使用した方が効率的です。
得られる行に含まれる列の数よりも要素数が少ない Object 配列を渡すこともできます。Object 配列が保持できる量のデータだけが、配列にコピーされます。既存の行に格納されている列の数よりも長い Object 配列を渡すこともできます。その場合、余分な配列要素はメソッドを呼び出した後も変化しません。

適切な大きさの配列を使用して、指定した DataTableReader の現在の行からすべての値を読み取る例を次に示します。また、使用可能な列の数と異なる可能性がある固定サイズの配列を使用する例も示します。
Private Sub TestGetValues(ByVal reader As DataTableReader) ' Given a DataTableReader, 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
private static void TestGetValues(DataTableReader reader) { // Given a DataTableReader, 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. Object[] values = new Object[reader.FieldCount]; int fieldCount = reader.GetValues(values); Console.WriteLine("reader.GetValues retrieved {0} columns.", fieldCount); for (int i = 0; i < fieldCount; i++) Console.WriteLine(values[i]); 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. values = new Object[3]; fieldCount = reader.GetValues(values); Console.WriteLine("reader.GetValues retrieved {0} columns.", fieldCount); for (int i = 0; i < fieldCount; i++) Console.WriteLine(values[i]); }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDataTableReader.GetValues メソッドを検索する場合は、下記のリンクをクリックしてください。

- DataTableReader.GetValues メソッドのページへのリンク