Share via


SqlCeDataReader.GetBytes 方法

從指定的資料行位移 (Offset) 將位元組資料流讀入做為陣列的緩衝區,開始於指定的緩衝區位移。

命名空間:  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
    以零為基底的資料行序數。
  • 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 命名空間