Accuracer: The First And Only BDE Alternative
Client-Server Single-File Embedded Database for Delphi / C++Builder / Kylix



BLOB fields use

Previous  Top  Next


Introduction

Use of BLOB fields in Accuracer 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.

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

TACRBlobStream 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 TACRBlobStream, 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 TACRBlobStream to access data from more than one record. Instead, create a new TACRBlobStream object every time you need to read or write BLOB data on a new record.

Example

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);
var
Buffer: PChar;
MemSize: Integer;
Stream: TACRBlobStream;
begin
Stream := TACRBlobStream.Create(MyAccuracer.FieldByName('Notes') as TBlobField, bmRead);
try
MemSize := Stream.Size;
Inc(MemSize); Make room for the buffer's null terminator.
Buffer := AllocMem(MemSize); Allocate the memory.
try
Stream.Read(Buffer^, MemSize); Read Notes field into buffer.
Memo1.SetTextBuf(Buffer); Display the buffer's contents.
finally
FreeMem(Buffer, MemSize);
end;
finally
Stream.Free;
end;
end;


© AidAim Software Accuracer: