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

Power Tip: Learn How to Send Arrays To An InterBase Database Using FireDAC In Delphi

The Arrays sample shows you how to use the TFDParam.ArrayType property to send arrays to a database server. To this end the ArrayType property is set to atTable.Note: This demo establishes a connection to the Interbase localhost server by default, using the SYSDBA user. You can change these parameters to connect to a different InterBase server using a valid user name and password.

Location

You can find the Arrays project at:

How to Use the Sample

  1. Navigate to the location given above and open IBArrays.dproj.
  2. Press F9 or choose Run > Run.
  3. Use the parameters by default to connect to the local InterBase server with the default SYSDBA user.
  4. Press the IBwrite and IBread buttons to send/recive arrays to/from a databse server.

Files

File in Delphi Contains
IBArrays.dproj
IBArrays.dpr
The project itself.
fMain.pas
fMain.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, you see a grid and two buttons labeled as: IBread and IBwrite. Both buttons have an OnClick event to do the following:

Press this button to send arrays to a database server. When you press this button, the sample takes the following steps:

  1. Uses the Text property of SQL to set the SQL command that FDQuery1 will execute.
  2. Sets the TFDParam.DataTypeName to specify the field name as <TableName>.<FieldName>.
  3. Sets the TFDParam.ArrayType property to atTable.Note: If you set it to atArray it does not work.
  4. Sets the array size with the TFDParam.ArraySize property.
  5. Sets the arrays using the AsStrings property:
  6. Sends the arrays to the database server by executing the SQL command specified in the first step.

Uses the Open method to read the arrays from the database server. The sample displays the arrays on the grid.

Please follow the link below if you want to see the original post:

http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.InterBase_Arrays_Sample

Head over and check out the full source code for the InterBase arrays sample for FireDAC in Delphi over on GitHub.

 

 
Exit mobile version