Share via


SqlCeDataReader.GetBytes メソッド

指定した列オフセットからのバイト ストリームを、配列としてバッファーに読み込みます。読み込みは、指定したバッファー オフセットから開始されます。

名前空間:  System.Data.SqlServerCe
アセンブリ:  System.Data.SqlServerCe (System.Data.SqlServerCe.dll)

構文

'宣言
<SecurityTreatAsSafeAttribute> _
<SecurityCriticalAttribute> _
Public Overrides Function GetBytes ( _
    ordinal As Integer, _
    dataIndex As Long, _
    buffer As Byte(), _
    bufferIndex As Integer, _
    length As Integer _
) As Long
'使用
Dim instance As SqlCeDataReader
Dim ordinal As Integer
Dim dataIndex As Long
Dim buffer As Byte()
Dim bufferIndex As Integer
Dim length As Integer
Dim returnValue As Long

returnValue = instance.GetBytes(ordinal, _
    dataIndex, buffer, bufferIndex, length)
[SecurityTreatAsSafeAttribute]
[SecurityCriticalAttribute]
public override long GetBytes(
    int ordinal,
    long dataIndex,
    byte[] buffer,
    int bufferIndex,
    int length
)
[SecurityTreatAsSafeAttribute]
[SecurityCriticalAttribute]
public:
virtual long long GetBytes(
    int ordinal, 
    long long dataIndex, 
    array<unsigned char>^ buffer, 
    int bufferIndex, 
    int length
) override
[<SecurityTreatAsSafeAttribute>]
[<SecurityCriticalAttribute>]
abstract GetBytes : 
        ordinal:int * 
        dataIndex:int64 * 
        buffer:byte[] * 
        bufferIndex:int * 
        length:int -> int64 
[<SecurityTreatAsSafeAttribute>]
[<SecurityCriticalAttribute>]
override GetBytes : 
        ordinal:int * 
        dataIndex:int64 * 
        buffer:byte[] * 
        bufferIndex:int * 
        length:int -> int64 
public override function GetBytes(
    ordinal : int, 
    dataIndex : long, 
    buffer : byte[], 
    bufferIndex : int, 
    length : int
) : long

パラメーター

  • ordinal
    型: System.Int32
    列の 0 から始まる序数。
  • dataIndex
    型: System.Int64
    読み取り操作の開始位置を示す、フィールド内のインデックス。
  • buffer
    型: array<System.Byte[]
    バイト ストリームの読み取り先のバッファー。
  • bufferIndex
    型: System.Int32
    読み取り操作を開始するための、buffer のインデックス。
  • length
    型: System.Int32
    バッファーにコピーする最大データ長。

戻り値

型: System.Int64
実際に読み取ったバイト数。

実装

IDataRecord.GetBytes(Int32, Int64, array<Byte[], Int32, Int32)

例外

例外 条件
InvalidOperationException

操作が有効ではありません。SqlCeDataReader が、結果セットの最後の行よりも後に置かれている可能性があります。

説明

GetBytes は、フィールド内の利用可能なバイト数を返します。ほとんどの場合、これは正確なフィールド長です。ただし、既に GetBytes を使用してフィールドからバイトを取得している場合は、返されるバイト数が、フィールドの実際の長さよりも小さくなることがあります。これは、SqlCeDataReader が、大きいデータ構造体をバッファーに読み込んでいるときなどに起こります。詳細については、CommandBehavior の SequentialAccess 設定のトピックを参照してください。

nullNULL 参照 (Visual Basic では Nothing) のバッファーを渡すと、GetBytes は、バイト単位のフィールド長を返します。

変換は実行されません。そのため、取得するデータはバイト配列である必要があります。

関連項目

参照

SqlCeDataReader クラス

System.Data.SqlServerCe 名前空間