SqlCeDataReader.GetChars 方法

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

命名空间:  System.Data.SqlServerCe
程序集:  System.Data.SqlServerCe(在 System.Data.SqlServerCe.dll 中)

语法

声明
<SecurityTreatAsSafeAttribute> _
<SecurityCriticalAttribute> _
Public Overrides Function GetChars ( _
    ordinal As Integer, _
    dataIndex As Long, _
    buffer As Char(), _
    bufferIndex As Integer, _
    length As Integer _
) As Long
用法
Dim instance As SqlCeDataReader
Dim ordinal As Integer
Dim dataIndex As Long
Dim buffer As Char()
Dim bufferIndex As Integer
Dim length As Integer
Dim returnValue As Long

returnValue = instance.GetChars(ordinal, _
    dataIndex, buffer, bufferIndex, length)
[SecurityTreatAsSafeAttribute]
[SecurityCriticalAttribute]
public override long GetChars(
    int ordinal,
    long dataIndex,
    char[] buffer,
    int bufferIndex,
    int length
)
[SecurityTreatAsSafeAttribute]
[SecurityCriticalAttribute]
public:
virtual long long GetChars(
    int ordinal, 
    long long dataIndex, 
    array<wchar_t>^ buffer, 
    int bufferIndex, 
    int length
) override
[<SecurityTreatAsSafeAttribute>]
[<SecurityCriticalAttribute>]
abstract GetChars : 
        ordinal:int * 
        dataIndex:int64 * 
        buffer:char[] * 
        bufferIndex:int * 
        length:int -> int64 
[<SecurityTreatAsSafeAttribute>]
[<SecurityCriticalAttribute>]
override GetChars : 
        ordinal:int * 
        dataIndex:int64 * 
        buffer:char[] * 
        bufferIndex:int * 
        length:int -> int64 
public override function GetChars(
    ordinal : int, 
    dataIndex : long, 
    buffer : char[], 
    bufferIndex : int, 
    length : int
) : long

参数

  • dataIndex
    类型:System.Int64
    行中的索引,从其开始读取操作。
  • buffer
    类型:array<System.Char[]
    要向其中复制数据的缓冲区。
  • bufferIndex
    类型:System.Int32
    从该处开始读取操作的 buffer 的索引。

返回值

类型:System.Int64
读取的实际字符数。

实现

IDataRecord.GetChars(Int32, Int64, array<Char[], Int32, Int32)

异常

异常 条件
InvalidOperationException

该操作无效。SqlCeDataReader 可能放置在结果集中的最后一行之后。

注释

GetChars 返回字段中可用字符的数目。大多数情况下,它是字段的确切长度。但是,如果 GetChars 已用于从字段中获取字节,则所返回的数字可能会小于该字段的真实长度。例如,如果 SqlCeDataReader 将一个大型数据结构读入缓冲区,则可能出现这种情况。有关详细信息,请参阅 CommandBehavior 的 SequentialAccess 设置。

如果传递为 nullnull 引用(在 Visual Basic 中为 Nothing) 的缓冲区,则 GetChars 以字符为单位返回字段的长度。

不执行任何转换,因此所检索的数据必须已经是字符数组。

请参阅

参考

SqlCeDataReader 类

System.Data.SqlServerCe 命名空间