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

Easy Steps To Connect To A MS Access Database With FireDAC In This Windows Sample App

Do you want your Delphi and C++ Builder Applications to connect with Access Database ? Do you need to manage some of the Access Database services such as creating, compacting database? How to start ? Don’t worry, FireDAC components offers robust components to connect with Access Database.

FireDAC.Access Sample app demonstrates how to use FireDAC to work with access Database.

You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.

Components used in the Sample App:

  • TFDQuery : To execute SQL queries, browse the result sets, and edit the result set records.
  • TFDPhysMSAccessDriverLink: To link the Microsoft Access driver to an application and set it up. In general, it is enough to only include the FireDAC.Phys.MSAcc unit into your application uses clause. It is used to specify access ODBC driver name and access the ODBC driver connection parameter common for all connections.
  • TFDConnection : To establish a connection to a DBMS and to manage associated datasets.
  • TFDAccessService: Class Implementing Microsoft Access database for creating, dropping, compacting, and repairing services.
  • And some of the UI components, like TDBGrid,TDBComboBox, TFDGUIxWaitCursor1,TFDGUIxLoginDialog1,TFDGUIxErrorDialog1

Implementation Details:

The simplest way to configure connection to MS Access database at run time is to build a temporary connection definition: In the sample, the temporary definition is created when the <Open database…> item is selected in the Connection combo box.  Open the following database: C:UsersPublicDocumentsEmbarcaderoStudio20.0SamplesdataFDDemo.mdb.

In the demo database, the Categories and Products tables have one-to-many relation by CategoryID field. Mention the query to the qryCategories.SQL property and qryProducts.SQL property.

Finally, qryProducts.MasterSource property is set to dsCategories, while the MasterFields property is set to CategoryID. This creates a master-details relationship between the datasets. Simple queries execution is demonstrated via the ExecSQL method of TFDConnection.

The management of databases, such as: creating, dropping, compacting/repairing, and setting a password is done using TFDMSAccessService component.

This demo demonstrates how to create and compact the user database.  Check out the full article in the DocWiki about the FireDAC.Access Sample.

<strong>FireDACAccess Sample App<strong>

Check out the full source code for the FireDAC.Access projects for Delphi and C++Builder over on GitHub.

Next, check out the how FMX Login Screens look like in this article.

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

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

Leave a Reply

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

IN THE ARTICLES