This sample describes how to use TFDGUIxLoginDialog in FireDAC GUI applications to allow users to enter their database credentials to connect to a DBMS. The same component also allows users to manage their passwords.
The sample connects to a database using a TFDConnection.
You can find the TFDGUIxLoginDialog sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
- Object Pascal\DataBase\FireDAC\Samples\Comp Layer\TFDGUIxLoginDialog\Main.
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
This sample uses the Use Connection Definition drop-down menu to select a connection definition. If the database requires login credentials and the Login prompt check-box is selected, the FireDAC Login window appears where the user can input the User name, Password and other optional parameters. The set of parameters depends on the database type. The Profile combo-box allows choosing one of the previously successfully used credentials.
How to Use the Sample
- Navigate to the location given above and open:
- Delphi: LoginDialog.dproj
- Press F9 or choose Run > Run.
- Select a connection definition from the Use Connection Definition drop-down menu.
- Click Connect to connect to the database.
- The FireDAC Login appears, allowing to input the login credentials.
- Click Disconnect to disconnect from the database.
This project uses the dmMainComp unit where the TFDGUIxLoginDialog component is placed.
Use Connection Definition
The menu shows all the connections defined on the file at C:\Users\Public\Documents\Embarcadero\Studio\FireDAC\FDConnectionsDefs.ini.
The connection to the database is established using a TFDConnection component placed at the dmMainComp unit. It uses the LoginDialog property from the TFDConnection to select the TFDGUIxLoginDialog component.
When selecting the connection, it updates the TFDGUIxLoginDialog properties with the values selected for the options on the FireDAC Login Dialog properties TPanel.
It updates the TFDGUIxLoginDialog properties with the values selected for the options on the FireDAC Login Dialog properties TPanel.
FireDAC Login Dialog properties
Values by default for the TFDGUIxLoginDialog properties:
- It allows the user to change an expired password.
- It allows the login history storage.
- It allows the password storage in the login history.
- Specifies the number of allowed login tries for the user. An exception is raised when the defined number is reached.
Database, User_Name and Password
- Specifies the fields shown on the FireDAC Login window. You can also set the name to be shown. For example
Database = My Database Connection.
If you want to ti visit the original Embarcadero post, refer to the link below:
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
Deep Dive Webinar: Boost C++Builder Compile Speed with TwineCompile