- The FireDAC Database Connection creates a table (test_vs) and inserts data from an XML document using a FireDAC database connection.
Note: The connection to the database does not require authentication.
How to Use the Sample
- Navigate to the location given above and open Project1.dproj.
- Press F9 or choose Run > Run.
- Click the Button1 button and the grid will be populated with data.
- Click the Button1 button again to deactivate the TFDQuery component and stop showing the data.
|Demo\Project1.dproj||Contains the project itself.|
|Demo\Unit1.dfm||Contains the code of the main form.|
|Demo\Unit1.pas||Contains the main form and the main code.|
|FireDAC.Comp.VSE.pas||Contains the code for the VSE class used for parsing the XML document.|
|FireDAC.Comp.VSEXML.pas||Contains the code for the VSEXML class used for XPath.|
- When the TForm is created, a TFDConnection executes a DROP query against the test_vs table, creates the table, and populates it with data from an XML document.
- The XML document is written at the beginning of the implementation part in the project.
- Click the Button1 button on the main form to display (or not) the data in a TDBGrid, using a TFDQuery, a TDataSource, a TFDGUIxWaitCursor, and a TFDPhysSQLiteDriverLink.
- The TFDQuery executes a SELECT query against the test_vs table and displays the results in a TDBGrid.
- The project uses procedures which are found in the FireDAC.Comp.VSE.pas and FireDAC.Comp.VSEXML.pas units to interact with the XML document.
- In the TForm creation procedure, a TFDVSEXMLManager (the FVS code variable) is instantiated and two TFDVSESchema (the oSch code variable) are created.
- The two TFDVSESchema variables have the following TFDVSECMLFieldDefs fields: Name, DataType, Size, and XPathExpression. One TFDVSESchema is used for Request and the other one for Response. They are used for parsing the XML document.
- The FVS Manager also adds a TFDVSESessions to allow the TFDQuery to execute the query.
If you want to check the original post with more information, refer to the link below: