Reading to a Data Stream

This tutorial describes how to copy data from a database into a data stream.


You can read data from the table into a data stream in one chunk or in bits as desired.

Basic procedure

The high level steps to read the data into a data stream are shown here:

  1. Configure your SQL statement and data stream.

  2. Read data to a stream.

  3. Clean up.

Detailed steps

To read the data into a data stream, do the following:

Configure your SQL statement and data stream

  1. As a first step instantiate an object of the RSqlStatement and RSqlColumnReadStream class. Also declare the variables as required.

    RSqlStatement myStatement;
    TInt err;
    TInt myColumnIndex;
    RSqlColumnReadStream myStream;
  2. Clean up the stack.


Read data to a stream

  1. Open the stream for read and associate the data with it.

  2. Determine the column size.

    TInt size = myStatement.ColumnSize(myColumnIndex);
  3. Instantiate an object of the RBuf class. Create a buffer of the size of the column. Then read the data into the buffer.

    RBuf buf;
  4. Close the buffer.


Clean up

Close the stream.