OleDbDataReader.GetBytes(Int32, Int64, Byte[], Int32, Int32) 方法

定义

从按指定的列偏移量将字节流作为数组从给定的缓冲区偏移量开始读入缓冲区。Reads a stream of bytes from the specified column offset into the buffer as an array starting at the given buffer offset.

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

参数

ordinal
Int32

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

dataIndex
Int64

字段中作为读取操作起始位置的索引。The index within the field from which to start the read operation.

buffer
Byte[]

要读入字节流的缓冲区。The buffer into which to read the stream of bytes.

bufferIndex
Int32

buffer 中写入操作开始位置的索引。The index within the buffer where the write operation is to start.

length
Int32

复制到缓冲区中的最大长度。The maximum length to copy into the buffer.

返回

读取的实际字节数。The actual number of bytes read.

注解

GetBytes返回字段中的可用字节数。GetBytes returns the number of available bytes in the field. 大多数情况下,这是字段的准确长度。Most of the time this is the exact length of the field. 但是,如果GetBytes已使用从字段获取字节,则返回的数字可能小于字段的实际长度。However, the number returned may be less than the true length of the field if GetBytes has already been used to obtain bytes from the field. 例如,当将一个大型数据结构读入缓冲区时OleDbDataReader ,可能会出现这种情况。This may be the case, for example, when the OleDbDataReader is reading a large data structure into a buffer. 有关详细信息,请参阅SequentialAccessCommandBehavior设置。For more information, see the SequentialAccess setting for CommandBehavior.

如果传递的缓冲区为null,则返回字段的长度( GetBytes以字节为单位)。If you pass a buffer that is null, GetBytes returns the length of the field in bytes.

不执行任何转换;因此,检索的数据必须已经是字节数组。No conversions are performed; therefore, the data retrieved must already be a byte array.

适用于

另请参阅