The Main sample shows you how to use different database functionalities related with the TFDMemTable class. To this end, the sample uses different properties and methods of the cited class. The following dataset features are implemented:
- Save a dataset data to a file.
- Load a dataset data from a file.
- Modify the fields and the indexes of the fields in a dataset.
- Define the client-side aggregating formulas.
- Filter a dataset to search for specific records.
- Set the beginning and ending range values for the dataset and apply the range.
- Clone a dataset.
Table of Contents
Location
You can find the Main sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
Object PascalDatabaseFireDACSamplesComp LayerTFDMemTableMain
- 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
CDS_main.dproj
. - Press F9 or choose Run > Run.
Files
File in Delphi | Contains |
---|---|
CDS_main.dproj CDS_main.dpr | The project itself. |
fMainDemo.pas fMainDemo.fmx | The main form. |
Implementation
The goal of this sample is to show how to implement different functionalities related with the TFDMemTable class. To this end, the sample first configures the main components:
- A TFDTable object named FDTable1
This component is used to browse a database table and edit its records. To this end, the ConnectionName property is set to SQLite_Demo
using the Object Inspector at design time.
- A TFDMemTable object named MT.
This component retrieves data from database through TFDTable. To this end, the sample implements a FormCreate event that uses the CopyDataSet method to copy on run time the records from FDTable1 to MT.
- A TDataSource object named DataSource1.
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 DataSet property of DataSource1 is set to MT
and the DataSource property of DBGrid1 is set to DataSource1
. This set up is done at design time using the Object Inspector.
When you run the application, you see a multiple page dialog and a table displayed on DBGrid1. The grid is used to display and manipulate records from MT. Once the grid is filled, you can interact with the sample by using the features that are implemented in each tab:
- Content
- Fields
- Indexes
- Aggregates
- Filter
- Ranges
- Clone
More detailsed information can be found on the link below:
http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.TFDMemTable.Main_Sample
Head over and check out the full source code for the main TFDMemTable demo on GitHub.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition