Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Easily Implement Robust Binary Large Object (BLOB) Streaming With FireDAC In Delphi

The Blobs sample shows you how to create a BLOB stream for reading and/or writing the value of a specific BLOB field on a specific record. To this end, the sample uses the CreateBlobStream method of TFDQuery to create a read-only BLOB stream. In this sample, the BLOB stream is used to read the picture contained on each BLOB field of each record of the Categories table.

Location

You can find the Blobs sample project at:

How to Use the Sample

  1. Navigate to the location given above and open Blobs.dproj.
  2. Press F9 or choose Run > Run.

Files

File in DelphiContains
Blobs.dproj
Blobs.dpr
The project itself.
fBlobs.pas
fBlobs.fmx
The main form.

Implementation

Before running the sample, the main components are configured at design time using the Object Inspector as follows:

When you run the application, the sample uses the CreateBlobStream method of TFDQuery with its mode set to bmRead in order to create a read-only BLOB stream. The BLOB stream is used to read the picture contained on the BLOB field of each record. Click on the Use Connection Definition combo box and select an option in order to define a connection. When you select an item of the combo box, the sample uses the Open method of qCategories in order to execute the SQL statement that retrieves the Categories table from the database. Then, the sample displays the Categories table using a TDBGrid component.

The original post of Embarcadero for this sample can be found in the link below:

http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.TFDQuery.Blobs_Sample

Head over and check out the full source code for working with blobs in FireDAC in Delphi.

Exit mobile version