diff -r 4816d766a08a -r f345bda72bc4 Symbian3/PDK/Source/GUID-183280EE-0C57-54FE-8ABB-E1CC3BDE525B.dita --- a/Symbian3/PDK/Source/GUID-183280EE-0C57-54FE-8ABB-E1CC3BDE525B.dita Tue Mar 30 11:42:04 2010 +0100 +++ b/Symbian3/PDK/Source/GUID-183280EE-0C57-54FE-8ABB-E1CC3BDE525B.dita Tue Mar 30 11:56:28 2010 +0100 @@ -1,20 +1,20 @@ - - - - - -Reading to a Data Stream

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

Introduction

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.

    CleanupClosePushL(myStream);

Read data to a stream

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

    User::LeaveIfError(myStream.ColumnBinary(myStatement,myColumnIndex));
  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; - buf.CreateL(size); - CleanupClosePushL(buf); - myStream.ReadL(buf,size); + + + + + +Reading to a Data Stream

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

    Introduction

    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.

      CleanupClosePushL(myStream);

    Read data to a stream

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

      User::LeaveIfError(myStream.ColumnBinary(myStatement,myColumnIndex));
    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; + buf.CreateL(size); + CleanupClosePushL(buf); + myStream.ReadL(buf,size);
    4. Close the buffer.

      CleanupStack::PopAndDestroy();

    Clean up

    Close the stream.

    CleanupStack::PopAndDestroy();
    See also

    Querying a Database

    Inserting a Row into a Table

    Deleting Rows from a Table

    Reading to a Buffer

    Reading to Memory

    Reading to a Data Stream - This document

    Writing to a Data Stream

    Performing Scalar Queries

    \ No newline at end of file