DataTableReader.GetValues メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataTableReader.GetValues メソッドの意味・解説 

DataTableReader.GetValues メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

DataTableReader現在の行の値を格納する Objects配列取得します

名前空間: System.Data
アセンブリ: System.Data (system.data.dll 内)
構文構文

Public Overrides Function
 GetValues ( _
    values As Object() _
) As Integer
Dim instance As DataTableReader
Dim values As Object()
Dim returnValue As Integer

returnValue = instance.GetValues(values)
public override int GetValues (
    Object[] values
)
public int GetValues (
    Object[] values
)

パラメータ

values

DataTableReader の列の値のコピー先である Object配列

戻り値
配列コピーされる列の値の数。

例外例外
例外種類条件

ArgumentOutOfRangeException

渡されインデックスが 0 から FieldCount - 1 の範囲にありません。

DeletedRowInaccessibleException

削除した行からデータ取得しようとしました

InvalidOperationException

閉じている DataTableReader の列を読み取るアクセスしようとしました

解説解説

アプリケーションでは、ほとんどの場合、このメソッド利用してすべての列をまとめて取得する方が、各列を個別取得するよりも効率的です。DataTableReader 内にある行から列の値をすべて取得する場合GetValues メソッド使用した方が効率的です。

得られる行に含まれる列の数よりも要素数が少なObject 配列を渡すこともできますObject 配列保持できる量のデータだけが、配列コピーされます。既存の行に格納されている列の数よりも長い Object 配列を渡すこともできますその場合、余分な配列要素メソッド呼び出した後も変化しません。

null 列の出力配列には DBNull置かれます。

使用例使用例

適切な大きさ配列使用して指定した 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]);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からDataTableReader.GetValues メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDataTableReader.GetValues メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDataTableReader.GetValues メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

DataTableReader.GetValues メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataTableReader.GetValues メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS