Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
CodeDatabaseDelphiInterBaseRAD Studio

Easily Establish an InterBase Temporary Connection Definition at Run-Time With Delphi

The InterBase getting started sample shows how to create a temporary connection definition at run-time with InterBase database. This sample allows the user to do:

  • Temporary¬†connection definition¬†at run-time.
  • Master-details relationship between datasets using¬†TFDQuery.
  • Transactions handling with¬†TFDTransaction.
  • Management of¬†InterBase¬†database such as: managing users, creating database backup/restoring database from backup and validating a database.

Location

You can find the InterBase sample project at:

  • Start | Programs | Embarcadero RAD Studio Sydney | Samples¬†and then navigate to:
    • Object PascalDatabaseFireDACSamplesGetting StartedInterBase
  • 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

  1. Navigate to the location given above and open GettingStarted.dproj.
  2. Press F9 or choose Run > Run.
  3. In the Database field, open the following database: C:ProgramDataEmbarcaderoInterBasegds_dbexamplesdatabaseemployee.gdb.

Files

File in Delphi Contains
GettingStarted.dproj
GettingStarted.dpr
The project itself.
fGettingStarted.pas
fGettingStarted.fmx
The main form.

Implementation

The sample implements the following features.

Creating temporary connection definition

The simplest way to configure connection to InterBase database at run-time is to build a temporary connection definition:

In the sample the temporary definition is created when the Connect button is clicked.

Master Details

In this sample, the Categories and Products tables have one-to-many relation by CategoryID field. The qryCategories.SQL property is set up as follows:

In addition, the qryProducts.SQL property is set up as follows:

Finally, the qryProducts.MasterSource property is set to dsCategories, while the MasterFields property is set to CategoryID. This creates a master-details relationship between the datasets.

Transaction handling

The handling of InterBase transactions is demonstrated using TFDTransaction + TFDConnection components. Both are configured as follows: trnMain.Connection property is set to dbMain connection and dbMain.Transaction property is set to trnMain.

Starting a transaction:

Committing the transaction:

Rolling back the transaction:

Executing queries

Simple queries execution is demonstrated via ExecSQL method of TFDConnection.

Updating records:

Getting a scalar value from the database:

Management of InterBase database

The sample application provides the following features:

  • Security management.
  • Database maintenance.
  • Tracing server activity

The management of databases is done using the following components TFDIBBackup, TFDIBRestore, TFDIBRestore, TFDIBSecurity, TFDIBTrace and TFDIBValidate.

Please refer to the link below for more information and external links about the sample:

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

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

 

InterBase Product Page

 

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Related posts
DelphiInterview

Developer Stories: Artur Majtczak Discusses His Superb ALLPlayer App

CodeDelphiRAD Studio

Modernize Your App: Are You Handling Windows Themes Correctly?

DelphiShowcase

Real World Drama In This Exciting GPS Motorcycle Game

DelphiShowcase

Ground-Breaking App For Transgender & Gender-Variant People

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES