SqlDataRecord.GetBytes(Int32, Int64, Byte[], Int32, Int32) SqlDataRecord.GetBytes(Int32, Int64, Byte[], Int32, Int32) SqlDataRecord.GetBytes(Int32, Int64, Byte[], Int32, Int32) SqlDataRecord.GetBytes(Int32, Int64, Byte[], Int32, Int32) Method

定义

获取此序号指定的列的值,其形式为 Byte 对象数组。Gets the value for the column specified by the ordinal as an array of Byte objects.

public:
 virtual long GetBytes(int ordinal, long fieldOffset, cli::array <System::Byte> ^ buffer, int bufferOffset, int length);
public virtual long GetBytes (int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length);
abstract member GetBytes : int * int64 * byte[] * int * int -> int64
override this.GetBytes : int * int64 * byte[] * int * int -> int64
Public Overridable Function GetBytes (ordinal As Integer, fieldOffset As Long, buffer As Byte(), bufferOffset As Integer, length As Integer) As Long

参数

ordinal
Int32 Int32 Int32 Int32

从零开始的列序号。The zero-based ordinal of the column.

fieldOffset
Int64 Int64 Int64 Int64

开始检索字节的字段值内的偏移量。The offset into the field value to start retrieving bytes.

buffer
Byte[]

要将字节复制到的目标缓冲区。The target buffer to which to copy bytes.

bufferOffset
Int32 Int32 Int32 Int32

要将字节开始复制到的缓冲区内的偏移量。The offset into the buffer to which to start copying bytes.

length
Int32 Int32 Int32 Int32

要复制到缓冲区的字节数。The number of bytes to copy to the buffer.

返回

已复制的字节数。The number of bytes copied.

实现

异常

ordinal 小于 0 或大于列数(即 FieldCount)。The ordinal is less than 0 or greater than the number of columns (that is, FieldCount).

ordinal 指定的列为 null。The column specified by ordinal is null.

注解

此方法使你能够在单个调用或块区中获取二进制值。This method enables you to obtain a binary value either in a single call or in chunks. 在区块中获取值对于大值或未知大小的值非常有用。Getting the value in chunks is useful for large values or values of unknown size.

若要获取多个块区中的值, 请分配块大小的字节数组, GetBytes并重复调用, fieldOffset并在每次调用时调整参数。To obtain the value in several chunks, allocate a byte array of the chunk-size and call GetBytes repeatedly, adjusting the fieldOffset parameter accordingly in each call.

适用于