DB2DataReader.GetBytes Method
Reads a stream of bytes 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
(inIBM.Data.DB2.dll
)
Syntax
[Visual Basic]
Public Function GetBytes( _
ByVal i As Integer, _
ByVal dataIndex As Long, _
ByVal buffer() As Byte, _
ByVal bufferIndex As Integer, _
ByVal length As Integer _
) As Long
[C#]
public long GetBytes(
int i,
long dataIndex,
byte[] buffer,
int bufferIndex,
int length
);
[C++]
public: __int64 GetBytes(
int i,
__int64 dataIndex,
unsigned char buffer __gc[],
int bufferIndex,
int length
);
[JScript]
public function GetBytes(
i : int,
dataIndex : long,
buffer : Byte[],
bufferIndex : int,
length : int
) : long;
Parameters
- i
- The zero-based column ordinal.
- dataIndex
- The index within the field where the read operation is to begin.
- buffer
- The buffer into which to read the stream of bytes.
- bufferIndex
- The index where buffer is to begin the write operation.
- length
- The number of bytes to read.
Return value
The actual number of bytes read.
Exceptions
Exception type | Condition |
---|---|
DB2Exception | Invalid conversion. |
Remarks
GetBytes returns the number of available bytes 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 GetBytes has already been used to obtain bytes from the field. This may be the case, for example, if the DB2®DataReader is reading a BLOB 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, GetBytes returns the length of the field in bytes.
No conversions are performed. The data
to be retrieved must be of one of the following types:
- DB2Type.Xml
- DB2Type.Binary
- DB2Type.VarBinary
- DB2Type.LongVarBinary
- DB2Type.Blob
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 |
---|---|---|
Xml | XML | |
Binary | BINARY, CHAR FOR BIT DATA | |
VarBinary | VARBINARY | |
LongVarBinary | LONG VARCHAR FOR BIT DATA | |
Blob | BLOB | BLOB, BYTE |