RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
C++CodeDelphi

Learn A Quick Way To Connect To A MySQL Database With The Delphi FireDAC Access Sample App

Do you want your Delphi and C++Builder Applications to connect with MySQL Database ? How to start ? Don’t worry, FireDAC offers robust components to connect with MySQL Database.

FireDAC.MySQL Sample app demonstrates how to use FireDAC to work with My SQL 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.
  • TFDPhysMySQLDriverLink: To link the MySQL driver to an application and set it up. In general, it is enough to only include the FireDAC.Phys.MySQL unit into your application uses clause. The TFDPhysMySQLDriverLink component can be used to specify: The VendorHome – the MySQL installation root folder. The VendorLib – the name and the optional path to the MySQL client library.
  • TFDConnection : To establish a connection to a DBMS and to manage associated datasets.
  • And some of the UI components, like TDBGrid,TDBComboBox, TFDGUIxWaitCursor1,TFDGUIxLoginDialog1,TFDGUIxErrorDialog1

Implementation Details:

The simplest to configure connection to MS SQL database at run-time is to build a temporary connection definition: In the sample, the temporary definition is created when clicking the Connect button. Check to how to connect to MySQL Server.

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, 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. Simple queries execution is demonstrated via ExecSQL method of TFDConnection. Check out the full article in the DocWiki about the FireDAC MySQL Sample.

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


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
CodeDelphiRAD Studio

Learn How To Use FireDAC In The Dynamic-Link Libraries With DLL Sharing Sample In Delphi

CodeDelphiRAD Studio

Learn How To Use Connection Pooling With A Multi-threaded Environment In Delphi

C++CodeDelphi

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

CodeDatabaseDelphiRAD Studio

Quickly Share Data Between Datasets Using CloneCursor In This Native Windows Sample For Delphi

Leave a Reply

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

IN THE ARTICLES