![firedacimagenotitle02 | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/06/firedac-image-no-title02.jpg?resize=1140%2C680&ssl=1)
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.
Table of Contents
Location
You can find the Blobs sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
Object PascalDatabaseFireDACSamplesComp LayerTFDQueryBlobs
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
How to Use the Sample
- Navigate to the location given above and open
Blobs.dproj
. - Press F9 or choose Run > Run.
![Bloobs | Embarcadero RAD Studio Delphi C++Builder Blogs](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2020/10/Bloobs.png?resize=750%2C444&ssl=1)
Files
File in Delphi | Contains |
---|---|
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:
- A TFDQuery object named qCategories. This component is used to implement a dataset capable of executing SQL queries. The following setup is needed:
- Configure the Connection property to specify the FireDAC connection object that is used to connect to a DBMS.
- Set the SQL property to
select * from {id Categories}
. It specifies the SQL statement to execute for the query.
- A TDataSource object named dsCategories. This component provides an interface between a dataset component and data-aware controls on a form. In this sample, it is used to provide communication between the dataset and the grid where the dataset is displayed. To this end, the following setup is needed:
- The DataSet property of dsCategories is set to
qCategories
. - The DataSource property of DBGrid1 is set to
dsCategories
.
- A TDBMemo object named DBMemo1. This component is used to display the Description field of the dataset. The following setup is needed:
- Set the DataSource property of DBMemo1 to
dsCategories
. - Set the DataField property of DBMemo1 to
Description
.
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.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition