SqlDataRecord.GetChars(Int32, Int64, Char[], Int32, Int32) SqlDataRecord.GetChars(Int32, Int64, Char[], Int32, Int32) SqlDataRecord.GetChars(Int32, Int64, Char[], Int32, Int32) SqlDataRecord.GetChars(Int32, Int64, Char[], Int32, Int32) Method

定义

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

public:
 virtual long GetChars(int ordinal, long fieldOffset, cli::array <char> ^ buffer, int bufferOffset, int length);
public virtual long GetChars (int ordinal, long fieldOffset, char[] buffer, int bufferOffset, int length);
abstract member GetChars : int * int64 * char[] * int * int -> int64
override this.GetChars : int * int64 * char[] * int * int -> int64
Public Overridable Function GetChars (ordinal As Integer, fieldOffset As Long, buffer As Char(), 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 characters.

buffer
Char[]

要将字符复制到其中的目标缓冲区。The target buffer to copy chars to.

bufferOffset
Int32 Int32 Int32 Int32

开始复制字符的缓冲区偏移量。The offset into the buffer to start copying chars to.

length
Int32 Int32 Int32 Int32

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

返回

复制的字符数。The number of characters 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 character value either in a single call or in chunks. 在区块中获取值对于大值或未知大小的值非常有用。Getting the value in chunks is useful for large values or values of unknown size.

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

适用于