FireDAC is Embarcadero’s library for universal data access – connection to just about any database protocol you can find. It abstracts the protocol-level details and presents a common interface so developers can build their applications to be database agnostic and flexible in the event of future design changes.
My work this week focused on FireDAC and local databases. SQLite is straightforward but FireDAC challenged me because, despite the many resources available, I couldn’t figure out how to get the initial connection set up without tutoring from @JimMcKeeth. Once demonstrated, the solution seemed simple and clarified my original problem as a low comprehension of FireDAC component relationships. As a visual learner, I needed a picture and couldn’t find one. My goal this week is to fill that visual gap for the new FireDAC developer.
As depicted, the three components needed to connect to a database are an FDConnection, an FDQuery or similar Query class, and a DataSource. The FDConnection handles the protocol of connecting to your database of choice, the FDQuery executes commands to request/modify data within the connected database, and the DataSource makes the information available to other components like a DBGrid. They connect in sequence: TDataSource to FDQuery to FDConnection. Once linked and the Connected/Active boxes are checked without an error message appearing, you can test the database by double-clicking the FDQuery, entering a command, and selecting “Execute”.
A word of warning – FireDAC won’t work with SQLite unless the correct DLL files are installed. Per the DocWiki instructions, download and extract the x64
C:\Windows\System32 and the x86
C:\Windows\SysWOW64. I didn’t follow all the configuration steps and it resulted in a
"Socket Error: Connection Closed" until the DLLs were in place.
Links to the mentioned resources:
- FireDAC Skill Sprints – Local SQL with Jim McKeeth
- Building Applications with FireDAC
- FireDAC in Depth with Cary Jensen
- Connecting to SQLite Database (FireDAC)
- FireDAC.SQLite sample
- FireDAC Skill Sprints (Playlist)
- FireDAC Greatest Hits (Playlist)
P.S. If you know SEO, help me get this image into search engine results!