OdbcDataReader.GetChars(Int32, Int64, Char[], Int32, Int32) 方法

定义

从指定的列偏移量将字符流作为数组从特定的缓冲区偏移量开始读入缓冲区。

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

从零开始的列序号。

dataIndex
Int64

行中读取操作开始位置的索引。

buffer
Char[]

要向其中复制数据的缓冲区。

bufferIndex
Int32

buffer 中写入操作开始位置的索引。

length
Int32

要读取的字符数。

返回

读取的实际字符数。

实现

注解

GetChars 返回 字段中的可用字符数。 大多数情况下,这是字段的确切长度。 但是,如果 GetChars 已用于从字段获取字符,则返回的数字可能小于字段的真实长度。 例如,如果 OdbcDataReader 正在将大型数据结构读取到缓冲区中,则可能是这种情况。 有关详细信息, SequentialAccess 请参阅 的设置 CommandBehavior

如果传递的缓冲区为 null 值, GetChars 则返回字段的长度(以字符为单位)。

转换基于 ODBC 驱动程序的基础功能执行。 如果转换不受支持,则方法调用将失败。

注意

如果 的值 bufferIndex 在数组之外,则不会引发异常。 不会读取任何数据,方法将返回 0。

适用于

另请参阅