EasyTable: Single-File Embedded Database,
a BDE replacement for Delphi and C++Builder

BLOB fields use
Previous  Top  Next


Use of BLOB fields in EasyTable is the same as in TTable component.
BLOB fields compression is transparent, so you can easily use it if you store large amounts of data in BLOB fields.

Use TEasyBlobStream to access or modify the value of a BLOB field in an EasyTable.
TEasyBlobStream is a stream object that provides services allowing applications to read from or write to field objects that represent Binary large object (BLOB) fields.

TEasyBlobStream allows objects that have no specialized knowledge of how data is stored in a BLOB field to read or write such data by employing the uniform stream mechanism.

To use a BLOB stream, create an instance of TEasyBlobStream, use the methods of the stream to read or write the data, and then close the BLOB stream. Do not use the same instance of TEasyBlobStream to access data from more than one record. Instead, create a new TEasyBlobStream object every time you need to read or write BLOB data on a new record.


The following example reads the data from a memo field into a blob stream and displays it in a memo control.

procedure TForm1.Button2Click(Sender: TObject);
Buffer: PChar;
MemSize: Integer;
Stream: TEasyBlobStream;
Stream := TEasyBlobStream.Create(MyEasyTable.FieldByName('Notes') as TBlobField, bmRead);
MemSize := Stream.Size;
Inc(MemSize); Make room for the buffer's null terminator.
Buffer := AllocMem(MemSize); Allocate the memory.
Stream.Read(Buffer^, MemSize); Read Notes field into buffer.
Memo1.SetTextBuf(Buffer); Display the buffer's contents.
FreeMem(Buffer, MemSize);

© AidAim Software EasyTable: Easytable Bde Alternative Single File Delphi Databas