OdbcDataReader.GetChars(Int32, Int64, Char[], Int32, Int32) 方法
定义
从指定的列偏移量将字符流作为数组从特定的缓冲区偏移量开始读入缓冲区。Reads a stream of characters from the specified column offset into the buffer as an array, starting at the particular buffer offset.
public:
override long GetChars(int i, long dataIndex, cli::array <char> ^ buffer, int bufferIndex, int length);
public:
virtual long GetChars(int i, long dataIndex, cli::array <char> ^ buffer, int bufferIndex, int length);
public override long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length);
public override long GetChars (int i, long dataIndex, char[]? buffer, int bufferIndex, int length);
public long GetChars (int i, long dataIndex, char[] buffer, int bufferIndex, int length);
override this.GetChars : int * int64 * char[] * int * int -> int64
abstract member GetChars : int * int64 * char[] * int * int -> int64
override this.GetChars : int * int64 * char[] * int * int -> int64
Public Overrides Function GetChars (i As Integer, dataIndex As Long, buffer As Char(), bufferIndex As Integer, length As Integer) As Long
Public Function GetChars (i As Integer, dataIndex As Long, buffer As Char(), bufferIndex As Integer, length As Integer) As Long
参数
- i
- Int32
从零开始的列序号。The zero-based column ordinal.
- dataIndex
- Int64
行中读取操作开始位置的索引。The index within the row where the read operation is to start.
- buffer
- Char[]
要向其中复制数据的缓冲区。The buffer into which to copy data.
- bufferIndex
- Int32
buffer 中写入操作开始位置的索引。The index within the buffer where the write operation is to start.
- length
- Int32
要读取的字符数。The number of characters to read.
返回
读取的实际字符数。The actual number of characters read.
实现
注解
GetChars 返回字段中的可用字符数。GetChars returns the number of available characters in the field. 大多数情况下,这是字段的准确长度。Most of the time this is the exact length of the field. 但是,如果 GetChars 已用于从字段获取字符,则返回的数字可能小于字段的真实长度。However, the number returned may be less than the true length of the field if GetChars has already been used to obtain characters from the field. 例如,如果 OdbcDataReader 正在将大数据结构读入缓冲区,则可能会出现这种情况。This may be the case, for example, if the OdbcDataReader is reading a large data structure into a buffer. 有关详细信息,请参阅的 SequentialAccess 设置 CommandBehavior 。For more information, see the SequentialAccess setting for CommandBehavior.
如果传递的缓冲区为空值,则 GetChars 返回字段的长度(以字符为间隔)。If you pass a buffer that is a null value, GetChars returns the length of the field in characters.
基于 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.