Description

The IncFetchingMSSQL sample shows you how to fetch rows from the current command cursor. To this end, the sample connects to the desired database using the MSSQL_Democonnection definition. Then, the sample uses
Fetch and FetchAll methods in order to fetch the rows that match with a given selection made by the user.

How to Use the Sample

Navigate to the location given above and open IncFetching.dproj.

Press F9 or choose Run > Run.

Files

File in Delphi

Contains

IncFetching.dprojIncFetching.dpr

The project itself.

Unit30.pasUnit30.fmx

The main form.

Implementation

This sample uses the following main components that are configured at design time using the Object Inspector:

It uses TFDConnection to connect to the desired database. In the CommandText property of TFDCommand there is a SQL command that, in this sample, is used for selecting the desired data from the desired database. In the sample, the CommandText property is set to: select * from Orders where EmployeeID = :ID, which means that, in this sample, the user can fetch the rows with a given value of the EmployeeID field from the Orders table. You can check it on the Object Inspector.

It provides communication between the application and the database. It is a mediator between TFDCommand and TFDMemTable. To this end, the SelectCommand property is set to FDCommand1 at design time using the Object Inspector.

Moreover, the goal of the sample is to fetch the desired rows from a given database table. First, the sample sets the condition that have to meet the rows in order to be selected; then, the sample uses the Open method to open the dataset and finally, calls the FetchAll method to fetch all rows that match with the desired selection. See the code below: