03 - Handling BLOB

Handling Binary Large Objects in a Database

While working with data and the large objects need to move between client application and the database server LOB (large object) data can be used. It uses technique to read the images and write them to a disk file by using streaming techniques. This will handle the data in chunks and will conserve the system resources.

Types of LOBs

· BLOB (Binary large object)

· CLOB (Character large object)

Retrieving BLOB Data

It can be retrieved from a database using a DataReader object. The normal operation of the DataReader object is to read one row at a time. To access the DataReader object as a stream, the behaviour of DbCommand object can be changed to a sequential stream at the time of execution of ExecuteReader( ) like as:


After retrieving the data it is converted into an array of bytes using GetBytes( ) method

Storing BLOB Data

BLOB data can be write to a database by executing INSERT or UPDATE statement. If BLOB data is in text format, it can be passed as a string parameter. If it is in binary format, such as an image field, it can be passed as a binary parameter.

Like us on Facebook