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

参数

  • 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 命名空间