You can find the IncFetchingMSSQL sample project at:
- Start | Programs | Appmethod 1.16 | Samples and then navigate to:
Object Pascal\Database\FireDAC\Samples\Comp Layer\TFDMemTable\IncFetching_MSSQL
- Subversion Repository:
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_Demo connection 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
- Select the iOS platform in the Project Manager.
- Press F9 or choose Run > Run.
|File in Object Pascal||Contains|
The project itself.
The main form.
This sample uses the following main components that are configured at design time using the Object Inspector:
- A TFDCommand object named FDCommand1.
- 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.
- A TFDTableAdapter object named FDTableAdapter1.
- 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
FDCommand1at design time using the Object Inspector.
- A TFDMemTable object named FDmemTable1.
- It retrieves data from database through TFDTableAdapter and TFDCommand. To this end, the Adapter property is set to
FDTableAdapter1at 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:
FDCommand1.Params.AsInteger := 1; FDMemTable1.Open; FDMemTable1.FetchAll;
- Note: This piece of code fetches all rows from the Orders table that have the value of the EmployeeID field set to
Then, this process is repeated in order to make an incremental fetch of rows that match the desired selection for each case. See the code below:
FDCommand1.Params.AsInteger := 2; // Fetching process FDCommand1.Params.AsInteger := 3; // Fetching process // ...