OdbcDataReader.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 particular buffer offset.

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

参数

i
Int32

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

dataIndex
Int64

字段中读取操作开始位置的索引。The index within the field where the read operation is to start.

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 number of bytes to read.

返回

读取的实际字节数。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. 例如,如果 OdbcDataReader 将大数据结构读取到缓冲区中,则可能会出现这种情况。This may be the case, for example, if the OdbcDataReader is reading a large data structure into a buffer. 有关详细信息,请参阅 CommandBehaviorSequentialAccess 设置。For more information, see the SequentialAccess setting for CommandBehavior.

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

基于 ODBC 驱动程序的基础功能执行转换。Conversions are performed based on the underlying capabilities of the ODBC driver. 如果不支持转换,则方法调用将失败。If the conversion is not supported then the method call will fail.

备注

如果 bufferIndex 的值超出数组,则不会引发异常。No exception will be thrown if the value of bufferIndex is outside the array. 将不读取任何数据,并且方法将返回0。No data will be read and the method will return 0.

适用于

另请参阅