DB2 Version 9.7 for Linux, UNIX, and Windows

DB2Blob.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.DB2Types
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax

[Visual Basic]
Public Function GetBytes( _
   ByVal dataIndex As Long, _
   ByVal buffer() As Byte, _
   ByVal bufferIndex As Integer, _
   ByVal length As Integer _
) As Long
[C#]
public long GetBytes(
   long dataIndex,
   byte[] buffer,
   int bufferIndex,
   int length
);
[C++]
public: __int64 GetBytes(
   __int64 dataIndex,
   unsigned char buffer __gc[],
   int bufferIndex,
   int length
);
[JScript]
public function GetBytes(
   dataIndex : long,
   buffer : Byte[],
   bufferIndex : int,
   length : int
) : long;

Parameters

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 bytes read.

Exceptions

Exception type Condition
DB2Exception Invalid conversion.
InvalidOperationException There is no more data to return.

Remarks

GetBytes 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 GetBytes has already been used to obtain characters from the field. This may be the case, for example, if the DB2Blob 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 characters.

If the CacheData property is false, applications can only retrieve the complete set of data from a DB2Blob instance once. Any additional attempts at retrieving data will result in an InvalidOperationException. The specific implications of this are:
  • This method can only be used to retrieve the complete set of data from a DB2Blob instance once.
  • If you use this method to retrieve data from a DB2Blob instance, you cannot use the Value property or the ToString method to do the same.
  • If you have already used the Value property or the ToString method to retrieve data from a DB2Blob instance, you cannot use this method to do the same.
If the CacheData property is true, data can be read from the DB2Blob structure, using any of the access methods.

Version information

Last update
This topic was last updated for: IBM DB2 Version 9.5
.NET Framework version
Supported in: 2.0, 3.0, 3.5, and 4.0
IBM Data Server Client
Supported in: IBM DB2 Version 9