DB2DataReader.GetChars Method

Reads a stream of characters from the specified column offset into the buffer as an array, starting at the given buffer offset.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax


[Visual Basic]
Public Function GetChars( _
   ByVal i As Integer, _
   ByVal dataIndex As Long, _
   ByVal buffer() As Char, _
   ByVal bufferIndex As Integer, _
   ByVal length As Integer _
) As Long
[C#]
public long GetChars(
   int i,
   long dataIndex,
   char[] buffer,
   int bufferIndex,
   int length
);
[C++]
public: __int64 GetChars(
   int i,
   __int64 dataIndex,
   __wchar_t buffer __gc[],
   int bufferIndex,
   int length
);
[JScript]
public function GetChars(
   i : int,
   dataIndex : long,
   buffer : Char[],
   bufferIndex : int,
   length : int
) : long;

Parameters

i
The zero-based column ordinal.
dataIndex
The index within the row where the read operation is to begin.
buffer
The buffer into which to copy data.
bufferIndex
The index where buffer is to begin the write operation.
length
The number of characters to read.

Return value

The actual number of characters read.

Exceptions

Exception type Condition
DB2Exception Invalid conversion.

Remarks

GetChars returns the number of available characters in the field. In most cases this is the exact length of the field. 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. This may be the case, for example, if the DB2®DataReader is reading a CLOB into a buffer. For more information, see the SequentialAccess setting of System.Data.CommandBehavior in the Microsoft(R) .NET Framework SDK documentation.

If you pass a buffer that is a null value. GetChars returns the length of the field in characters.

No conversions are performed. The data to be retrieved must be one of the following types:
  • DB2Type.Char
  • DB2Type.VarChar
  • DB2Type.LongVarChar
  • DB2Type.Clob
  • DB2Type.Graphic
  • DB2Type.VarGraphic
  • DB2Type.LongVarGraphic
  • DB2Type.DbClob
The following table describes the mapping between the return object data type and the data server data type.
DB2Type Data Type Db2® Data Type Informix® Data Type
Char CHAR CHAR
VarChar VARCHAR VARCHAR
LongVarChar LONG VARCHAR LVARCHAR
Clob CLOB CLOB, TEXT
Graphic GRAPHIC  
VarGraphic VARGRAPHIC  
LongVarGraphic LONG VARGRAPHIC  
DbClob DBCLOB